javascript - jquery function called twice -
i have working on ajax search functionality facing 1 issue.let me quick explain sample code below.
function search_content(sh_val,sh_act) { ....some search code..... window.location.hash = sh_val+'@'+sh_act; }
i have use following function restore search when clicked on browser or forward button.
$(window).bind( 'hashchange', function(e) { var pagee=location.hash.slice(1) if (pagee!="") { search_content(pagee,'catsh'); } return false; });
but facing issue when search ajax search function called twice. $(window).bind( 'hashchange') called when searching.is there way call above function browser , forward button or other solution ?
how can resolve issue?
i appreciate anykind of help..
try .on()
instead of bind , manual triggers. stop propagation maybe? why applying on window instead of document?
you can add debugger command :
$(window).on( 'hashchange', function(e) { debugger; e.stoppropagation(); [...] });
Comments
Post a Comment