bernat / best_in_place

A RESTful unobtrusive jQuery Inplace-Editor and a helper as a Rails Gem
http://blog.bernatfarrero.com/in-place-editing-with-javascript-jquery-and-rails-3/
1.2k stars 571 forks source link

Jquery and Popstate conflict #511

Closed ajinkya12 closed 8 years ago

ajinkya12 commented 8 years ago

I am using history.pushState to change the url without loading the page. When browser's back/forward button is clicked, a 'popstate' event is fired which I capture using

window.addEventListener('popstate', function (e) { // something });

The code above does proper Url changes, however,after execution of eventListener function, the code snippet below reverts the Url to default Url i.e. removes all the url changes.

if ( !eventHandle ) {
    elemData.handle = eventHandle = function( e ) {
   // Discard the second event of a jQuery.event.trigger() and
  // when an event is called after a page has unloaded
  return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
             jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
             undefined;
     };

How can the issue be addressed? Thank you.