├── README.md
├── jquery.querystring.js
└── tests
├── index.html
├── jquery.min.js
├── qunit.css
├── qunit.js
└── tests.js
/README.md:
--------------------------------------------------------------------------------
1 | This plugin attempts to make working with querystrings easier. The primary function exposed is `$.querystring`, which handles both parsing & serialization (depending on the type of argument passed in). A `$.fn.querystring` method is also provided, which makes getting & setting the querystring of `` elements more convenient.
2 |
3 | _Currently only the simplest cases work, but the goal is to support nested objects and arrays. Please refer to the test suite for more info._
4 |
5 | Basic usage
6 | -----------
7 |
8 | Objects can be serialized to a querystring fragment:
9 |
10 | $.querystring({name: "John", age:42}); // "name=John&age=42"
11 |
12 | Conversely, querystring fragments can be parsed back into objects:
13 |
14 | $.querystring("name=John&age=42"); // {name: "John", age:42}
15 |
16 | Element methods
17 | ---------------
18 |
19 | You can access an element's querystring directly:
20 |
21 | // Markup: Search for bikes!
22 | $('a').querystring(); // {terms: 'bicycles'}
23 |
24 | and modify it, too:
25 |
26 | $('a').querystring({perPage: 10});
27 | // Search for bikes!
28 |
29 | You'll notice the new parameter was merged into the existing querystring. You can optionally pass a second argument (boolean) indicating if the existing querystring should be cleared:
30 |
31 | $('a').querystring({foo: 'bar'}, true);
32 | // Search for bikes!
33 |
34 | You can also use this to remove the querystring:
35 |
36 | $('a').querystring({}, true);
37 |
38 | _Right now only `` tags are supported, but support for `