Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a function that is currently triggered by a focusout of an input element via

$('#wrapper').on('focusout','input[name=state]',function(){ 
    /* execute function */
});

The problem I am having is if someone decides to just skip that element with say a mouse click (as this input element is auto filled using the ziptastic plugin) then the function will not trigger. I tried .on('change') but that did not seem to work.

What would be the best way to trigger this function once input[name=state] has been filled out.

share|improve this question
add comment (requires an account with 50 reputation)

2 Answers

up vote 1 down vote accepted

Add a change event handler too:

$('#wrapper').on('focusout change','input[name=state]',function(){

And then also trigger the change event ($('#wrapper input[name=state]').change()) after the ziptastic plugin has been run. The change event won't fire if the value is set by .val("something").

share|improve this answer
add comment (requires an account with 50 reputation)

You can use onchange, it occurs either before or after the onblur.

share|improve this answer
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.