I create Pinterest as modal overlays using Rails 4. They are displayed in a translucent overlet on an endless scroll page.
Currently, when you click on a link, the browser history changes to display the item you are viewing. However, I have an exit button that, when pressed, I would like it to remove the overlay (which it already does), but then change the URL without losing the user's place in the infinite scroll.
How exactly does pinterest perform a URL change without updating the last page? I would use pushState with '/', but I have several types of infinite scroll pages and I would like the script to work for all of them.
application.js
if (history && history.pushState){
$(function(){
$('body').on('click', 'a', function(e){
$.getScript(this.href);
history.pushState(null, '', this.href);
});
$(window).bind("popstate", function(){
$.getScript(location.href);
});
});
}
close overlay script
function removeDabble() {
history.back(-1);
/*var elem = document.getElementById('artview');
elem.parentNode.removeChild(elem);
return false;*/
}