I have a page on which I list the members of my team (show_crew.php). The page works with an endless scroll plugin, such as Google images. First I show 10 entries. If the user reaches the bottom of show_crew.php, the new "show_crew.php" is added to the old one, showing the next 10 entries.
I carry some jQuery functions built into show_crew.php where I bind events through
$('body').on('click', 'myButton[rel=<? echo $user['id'] ?>]', function() { console.log('foo'); })
Now that show_crew.php is added several times, the event is also bound to the same button several times. I can solve this problem through $('body').off('click', 'myButton') EVERY TIME.
It looks ugly. Is there a more elegant way?
thank you matte
source share