I have a number of div elements in my page rendered using knockout variable to control how many divs are shown per page. When the page is initially rendered I set the value of this to 5 and bind mouseout event to each of the div using jquery hoverintent plugin. When a user clicks on Show more link I set the value of the max div t o10 and now 10 div elements are shown but only first 5 have the mouseout event binding. If I call the bind call again now the first 5 elements have 2 events attached to them. I can see the number of events using
$("div.ratingbig").data('events').mouseout
My question is how to remove the original binding before attaching the events again. Or is there a way to attach events for only new elements.
I added the following statements to remove existing hoverIntent from div elements if it existed before adding it which will insert mouseout events
Therefore each time before adding hoverintent it will check if the event already existed and if it did, it will be deleted first. Now I can call the above after changing the value of knockout variable and all elements get the hoverIntent.