I am showing a tabbed interface using jQuery. When you click the tab, the ajax call replaces all the html from the element with the $(".content")new html, using something like
$(".content")
$(".content").html(response);
When I do this, are all jquery events and functions that are attached to the elements inside the .contentdiv deleted? Is it possible to resume these events and functions after replacing the HTML? If I click on the tabs 324523452354 times, will it duplicate jQuery data each time?
.content
Yes. They will be deleted. You can use a live event to join elements that do not yet exist.
$(".myElementClass").live("click", function (e) { e.preventDefault(); //do stuff });
myElement , DOM.
myElement
HTML , , , DOM. , :
<div id="mine"> <ul> <li>One thing</li> </ul> </div>
:
$('div#mine').html("hey");
HTML :
<div id="mine"> hey </div>
, , . , jQuery.live(), , , . DOM, , , .
**.live** , ,
**.live**
http://www.bennadel.com/blog/1751-jQuery-Live-Method-And-Event-Bubbling.htm