Issue
I made a jQuery function that binds some fields, but it doesn't work when I add a new inline.
The main problem is that I don't know how to detect the insertion in DOM and bind it to my function.
Solution
Use the live
or delegate
functions to bind to form elements. They will continue working even after you insert new form elements, and you don't need to re-attach the event handlers every time.
Related questions:
- Binding dynamically created elements in jQuery
- Event binding on dynamically created elements?
- jQuery how to bind onclick event to dynamically added HTML element
- adding a new dom element, want to rebind
Answered By - Anurag
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.