Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created September 18, 2009 01:13
Show Gist options
  • Save cowboy/188817 to your computer and use it in GitHub Desktop.
Save cowboy/188817 to your computer and use it in GitHub Desktop.
// API
// 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
// window.onhashchange
$.setHash( params, merge_mode ); // set document hash
$(window).bind( 'hashchange', callback ); // add cross-browser support for this event!
// $.fn stuff:
// merge params into pre-existing url (or nothing) stored in attribute, optionally
// parsing params using parse array/function
$.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