How to prevent stacking the URL of chained dialogs

2019-07-25 08:48发布

问题:

When you chain dialog boxes in jQuery Mobile there are these "&ui-state=dialog&ui-state=dialog..." strings stacked on the URL. Is there a way to prevent this?

Thnx!

回答1:

  • What you can try is to add rel=external to the links which open the dialogs.
    This attribute will disable the Ajax navigation and should prevent stacking the URL.

  • You could also try the pushState plugin:

There is an optional feature that converts the longer, hash-based URLs mentioned in the previous section into the full document path which is cleaner and makes the Ajax tracking transparent in the URL structure. This is built as an enhancement on top of the hash-based URL system for Ajax links. Note that despite the name, this feature technically converts hash-based URLs by using history.replaceState (not history.pushState) in the current release because this works more reliably across our target platforms. For browsers that do not support history.replaceState, or if this feature is disabled, hash-based URLs will be used instead.

Since the plugin initializes when the DOM is fully loaded you can enable and disable it manually by setting $.mobile.pushStateEnabled global configuration option to false anytime before document ready.

You can check the online doc for more information:

http://jquerymobile.com/demos/1.2.0/docs/pages/page-navmodel.html