Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript change url parameter before putting it in history
    text
    copied!<p>I'm using the datatables JQuery plugin. I use it with AJAX and pagination (server-side). Each row contains a link to a detailed view of that record. When clicking in that link and then on the back button I want to return to the previous page. (Note: datatables own state-saving can't be used).</p> <p>This could be achieved If you could add a url parameter to the current url before it is put into the history.</p> <p>Can this be done? pure JS or JQuery does not really matter.</p> <p>(Note: I'm quite new do this kind of stuff, have read about using the # for this but never done it so if you recommend that please provide an example applicable to my problem)</p> <p>EDIT:</p> <p>Very basic Guide for JQuery plugin bbq (http://benalman.com/projects/jquery-bbq-plugin/)</p> <p>Assuming URL has a hash of #a=2&amp;b=test, you can get the values by:</p> <pre><code>//true = optional converts 2 to an integer, false to boolean,... var a = $.bbq.getState('a',true); </code></pre> <p>You can change/add a value by:</p> <pre><code>var hash = "a=3&amp;b=hello"; $.bbq.pushState(hash); </code></pre> <p>pushState fires hashchange Event in case it is bound. To bind the event but following in doucment.ready function:</p> <pre><code>// called when # part of URL is modified $(window).bind( 'hashchange', function( event ) { var hash = event.fragment; // full hash as string var a = event.getState('a', true ); // value for a // here do meaningful action like an AJAX request using the hash parameters }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload