Created
September 18, 2009 12:23
-
-
Save cowboy/189027 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// API | |
// history, window.onhashchange | |
$.history.add( params, merge_mode ); // set new 'state' (into location.hash, triggers hashchange event) | |
$.history.retrieve( key, coerce ); // get current 'state' (from location.hash, wrapper for $.deparam.hash) | |
$(window).bind( 'hashchange', function(e){ | |
e.hash; // the current 'state' as normalized hash string | |
e.retrieve(); // like $.history.retrieve but for this specific state | |
}); | |
$(window).trigger( 'hashchange' ); // trigger bound callbacks (like on page load, to handle the state it loaded with) | |
// all deparam methods return an object | |
$.deparam( params, coerce ) // deserialize params string, optionally coercing true, false, undefined, numbers | |
$.deparam.qs( coerce ); // get document query string as object | |
$.deparam.hash( coerce ); // get document hash as object | |
$.deparam.qs( params_or_url, coerce ); // get params from url or params string as object | |
$.deparam.hash( params_or_url, coerce ); // get params from url or params string as object | |
// all param methods return a string | |
$.param( params ) // serialize params string (jQuery built-in) | |
$.param.qs(); // get document query string as string | |
$.param.hash(); // get document hash as string (fixing ff issues) | |
$.param.qs( params_or_url ); // get params from url or params string as string with leading ? | |
$.param.hash( params_or_url ); // get params from url or params string as string with leading # | |
$.param.qs( url, params, merge_mode ); // get full url string with params merged into search ? | |
$.param.hash( url, params, merge_mode ); // get full url string with params merged into fragment # | |
$.param.attr( obj ); // a way to specify default attr-per-elem for $.fn.qs / $.fn.hash | |
// $.fn stuff: | |
// merge params into pre-existing url (or empty string) stored in attribute | |
$.fn.qs( attr, params, merge_mode ); | |
$.fn.hash( attr, params, merge_mode ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment