Use jQuery after loading new data
I'm using infinite scroll, one that I wrote, to load new data on scroll. The data that loads is a list that I need to be able to recognize with a .hover event.
--> $(".tagItem").hover(function () { ... }
But the new data with the tagItem attribute are not recognized by the hover event.
How can I have the new data be recognized by jQuery events???
This is my infinite scroll... it works just fine. After the new data is loaded, I am unable to use jQuery hover on it.
- function InfiniteScroll() {
- //$('#divPostsLoader').html('<img src="http://i.imgur.com/6RMhx.gif">');
- var $updatedboxes;
- var itemcount = $(".masonryContainer > div").length + 1;
- var daycycle = getParameterByName("d");
- //alert(itemcount);
- //send a query to server side to present new content
- $.ajax({
- type: "POST",
- url: "xxxx",
- data: "{itemIndex:'" + itemcount + "', dayCycleId:'" + daycycle + "'}",
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function (data) {
- if (data != "") {
- $appendedDivs = $(data.d).css({ opacity: 0 });
- $appendedDivs.imagesLoaded(function () {
- // show elems now they're ready
- $appendedDivs.animate({ opacity: 1 });
- $('#masonryContainer').append($appendedDivs);
- $('#masonryContainer').masonry('appended', $appendedDivs, true);
- });
- }
- //$('#divPostsLoader').empty();
- }
- })
- };