Skip to main content

Bug Tracker

Side navigation

#11203 closed bug (invalid)

Opened January 21, 2012 10:26AM UTC

Closed January 21, 2012 03:59PM UTC

.on method doesn't work with ajax loaded content

Reported by: anonymous Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

e.g: $('.page_bar').on("click","a",function(){ do something.....});

It doesn't work if the content .page bar is loaded via ajax....

Attachments (0)
Change History (1)

Changed January 21, 2012 03:59PM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

http://api.jquery.com/on/

Event handlers are bound only to the currently selected elements; they must exist on the page at the time your code makes the call to .on(). To ensure the elements are present and can be selected, perform event binding inside a document ready handler for elements that are in the HTML markup on the page. If new HTML is being injected into the page, select the elements and attach event handlers after the new HTML is placed into the page. Or, use delegated events to attach an event handler, as described next.