The use of mobile-side applications in Jquerymobile may require consideration of the parameter issues associated with page jumps. Because Jquerymobile is actually the result of HTML5 practice. HTML5 is used in Localstorage and sessionstorage. It's best to use storage to make it easier to use.
For example, on page a jump B page, before a jump to the jump parameters injected into the localstorage, the B page initialization to get localstorage related page parameters. and do the corresponding processing at the same time on the appropriate page cleanup page parameters.
Storage.js content is as follows:
JS Code
- function Kset (key, value) {
- Console.log ("key" +key+"value" +value);
- Window.localStorage.setItem (key, value);
- }
- function Kget (key) {
- Console.log (key);
- return Window.localStorage.getItem (key);
- }
- function Kremove (key) {
- Window.localStorage.removeItem (key);
- }
- function Kclear () {
- Window.localStorage.clear ();
- }
- Test the Update method
- function Kupdate (key,value) {
- Window.localStorage.removeItem (key);
- Window.localStorage.setItem (key, value);
- }
Examples are as follows:
The simple package is as follows:
JS Code
- Temporary storage
- var Tempcache = {
- Cache:Function (value) {
- Localstorage.setitem ("Easywaytempcache", value);
- },
- GetCache:function () {
- return Localstorage.getitem ("Easywaytempcache");
- },
- SetItem:function (key,value) {
- Localstorage.setitem (Key,value);
- },
- GetItem:function (key) {
- return Localstorage.getitem (key);
- },
- RemoveItem:function (key) {
- return Localstorage.removeitem (key);
- }
- };
Content on page A:
Bind all Workorderclass-style div
To set the relevant page parameters:
Java code
- Associated information for a list of bound views
- function Bindlistview (changedata) {
- $ (". Workorderclass"). each (function () {
- $ (This). Click (function () {
- //The number of the binding order, easy to use in the next page switch
- Tempcache.setitem ("order_function_mgr_id", $ (this). attr ("id"));
- Tempcache.setitem ("order_function","serviceorderfunction");
- Tempcache.setitem ("Order_function_mgr_id_w", $ (this). attr ("id"));
- });
- });
- }
In the initialization method of page B:
Use and clear the storage of the page in a timely manner.
JS Code
- //Work order display initialization information
- function Displayworkorder () {
- //The number of the binding order, easy to use in the next page switch
- var workorderid=tempcache.getitem ("order_function_mgr_id");
- Workorderid=workorderid.replace (/(^\s*) | ( \s*$)/g,"");
- //tracking work order sources
- Functionname=tempcache.getitem ("order_function");
- Functionname=functionname.replace (/(^\s*) | ( \s*$)/g,"");
- if (workorderid!=') {
- Queryworkorderinfo (Workorderid,functionname);
- Tempcache.removeitem ("order_function_mgr_id"); }else{
- Alert ("Service request failed, please try again later ....");
- }
- }
If you do not understand the place, welcome to communicate Thank you!