javascript - History.js first load -


i'm using history.js jquery.

my page search engine.

the form submitted via $.ajax() , result loaded in div#results pagination. click on next page's link handled $.ajax too.

each result link page.

when first load form, want div#results empty. when click on result's link button, want div#results same results.

$('.link_page').on('click', function(e){     e.preventdefault();     var page = $(this).data('page');     $.ajax({       url: '/search',       method: 'post',       data: {         create_date : $('#create_date').val(),         page        : page       }      }).done(function( html ) {       $( "#results" ).html( html );       history.pushstate({results: html}, "search", "/search");     });   });  history.adapter.bind(window, 'statechange', function (evt) {   var state = history.getstate();   $( "#results" ).html( state.data.results ); });  history.adapter.ondomload(function(){   var state = history.getstate();   history.replacestate({results: state.data.results}, "search", "/search"); }); 

it works if submit form go pages of site , return form, div#results still filled previous search.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -