Bug Tracker

Modify

Ticket #11203 (closed bug: invalid)

Opened 16 months ago

Last modified 16 months ago

.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:
Blocking: Blocked by:

Description

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

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

Change History

comment:1 Changed 16 months ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

 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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.