Side navigation
#10937 closed bug (invalid)
Opened December 01, 2011 02:02PM UTC
Closed December 01, 2011 02:04PM UTC
.on does not work for newly added elements
Reported by: | nikola@petkanski.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I'm using ajax to fetch the content for a dialog I'm displaying using jquery ui. The following handler fails to attach for any of the input elements on the fetched html code:
$('input').on('click', function(){ alert('clicked!'); });
It does work, however, if using '.live'.
Example code:
http://www.petkanski.com/test/jquery/on-bug/test.htm
The example code sets on() and live() hooks for the two buttons and fetches an ajax call containing them. You will see, that only one of the fetched buttons is operational. The button which was supposed to be hooked via '.on()' does not work.
Attachments (0)
Change History (1)
Changed December 01, 2011 02:04PM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
That's not how you use
.on()
for delegated events. Please read the documentation or ask for help on the forum.