javascript - onepage_scroll.js on Ajax content causes multiple keypress events -


i using onepage_scroll.js plugin

main.onepage_scroll({     loop: false,     animationtime: 750,     pagination: false }); 

as using ajax pull in new content - when ajax request added, functionality onepage_scroll not being updated new content.

i tried run onepage_scroll plugin again on ajax success, seems poor performance choice, , bit hack-y, got closest success able achieve.

beforesend: function() {     $('<span class="loading"></span>').hide().prependto('body').fadein(300);     main.addclass(removingclass);     settimeout(function() {         main.empty();     }, 750); }, success: function(data, textstatus, xhr) {     settimeout(function() {         $('.loading').remove();         main.html(data).removeclass().removeattr('style');         main.onepage_scroll({             loop: false,             animationtime: 750,             pagination: false         });     }, 750); } 

as can see, had remove classes added (via onepage_scroll) , remove inline styles (also onepage_scroll) before calling plugin again.

besides being hacky, left key events (up key scroll up, down key scroll down, space go down, shift+space go up) running multiple times, 1 additional scrolled panel per time i've called ajax request (ie: 2 ajax requests causes 1 keypress scroll 3 panels).

is there way automatically add onepage_scroll functionality newly added ajax content, without having call entire plugin again? or possibly way keep original keypress functionality after ajax call?

thanks help!

thanks quick response - took unbinding keydown functionality with:

$(document).unbind('keydown');

i run whenever call onepage_scroll plugin, , right in world!


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -