Ajax Paging - Enable Back Button

Possible duplicate:
How to perform: Support for the "Ajax" button on the "Back" button

I have an ASP.NET MVC implementation in which I get partial views through jQuery for things like paging and filtering. The problem is that I am breaking the browser button by doing this. How to restore the behavior of the return button (rewrite the URL without updating with the pound? You don’t know how it works, and how to retrieve the data when you click the "Back" button).

Thank you for your help!

+3
source share
3 answers

, javascript paging "" . . , "" , # URL-. "" ( ), URL- , .

EDIT:

URL-:

var baseURL = location.href.slice(0, location.href.indexOf('#'));

URL :

location.href = baseURL + '#page2';
//you'll probably want to figure out the page number programatically

:

$(goToResource);
function goToResource() {
    var hashURL = location.href.slice(location.href.indexOf('#'));
    //you AJAX code to load the resource goes here
}

, , .

+3
+4

Note the addition of browser history history on this page.

The article does not mention that this does not work for IE out of the box. You will need to enable the iframe on your page to make it work with IE.

<iframe id="__historyFrame" style="display:none;" ></iframe>

I only tested in IE7 and Firefox. Given the undocumented issue with IE, I'm not sure if it will work in a wide range of browsers.

+1
source

Source: https://habr.com/ru/post/1712408/


All Articles