* smeranda <[EMAIL PROTECTED]> [2006-11-21 16:55]:
>
> I have a page which creates dynamic text inputs through AJAX. I would like to
> run a function when the value inside the input is changed by the user.
> However, the following code doesn't seem to work on the dynamically created
> inputs (it does work for the static text inputs). Any ideas what I'm doing
> wrong?
>
> $("input").change(indicateChange);
>
> function indicateChange(foo) {
> alert("Item has changed Part II"); //continue with the required
> function
> code.
> }
First, I'm surprised it works, because it seems that you're defining
the event handler after you've referenced it as a parameter to the
change function. Is this possible?
Secondly, as someone else noted, dynamically added inputs will have
to have their change handler assigned. The $ method iterated the
document and applies the method chain to all matching elements.
When you subsequently add elements to the document, you need to set
the event handlers of the newly added elements.
It would work to rerun your $("input").change(indicateChange) method
after you've added new elements. Come back if that's too slow.
--
Alan Gutierrez - 504 717 1428 - [EMAIL PROTECTED] - http://blogometer.com/
Think New Orleans - http://thinknola.com/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/