Bug Tracker

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#14553 closed bug (notabug)

Ajax + Live (.on event)

Reported by: LyonSH@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

Description

// Analog .live in other jQuery
$(".class1").on("click", ".class2", function(){

       alert("work?");

});
// Example - Ajax Next Page
$("body").html('<div class="class1"><div class="class2">Not working!</div></div>');

Not working.

Change History (3)

comment:1 Changed 5 years ago by scottgonzalez

Resolution: notabug
Status: newclosed

It's working just fine. That's not actually an equivalent for what you want, since you're binding to .class1, but that element (if it even exists) is removed as soon as you replace the entire body content. Please ask for help on the forums or Stack Overflow.

comment:2 in reply to:  1 Changed 5 years ago by anonymous

// Working jQuery 1.7.1
$(".class1 .class2").live("click", function(){

       alert("work!");

});
// Analog - Not Working jQuery 1.10.2
$(".class1").on("click", ".class2", function(){

       alert("work?");

});
// Example - Ajax Next Page
$("body").html('<div class="class1"><div class="class2">Not working!</div></div>');

comment:3 in reply to:  1 Changed 5 years ago by LyonSH@…

I'm sorry. Understood...

Analog - Working jQuery 1.10.2 $(document).on("click", ".class1 .class2", function(){

alert("work?");

});

Note: See TracTickets for help on using tickets.