在JQueryMobile开发手机端应用使用可能需要考虑相关的页面跳转带来的参数问题。因为JQueryMobile其实也是HTML5实践的结果。HTML5中有localStorage和sessionStorage使用。最好采用Storage实现比较简单易用。

例如在页面A跳转B页面,在A跳转前将跳转参数注入到localStorage中,在B页面初始化获取localStorage相关的页面参数。并做相应的处理同时在适当的页面清理页面参数。

storage.js内容如下:

  1. function kset(key, value){
  2. console.log("key"+key+"value"+value);
  3. window.localStorage.setItem(key, value);
  4. }
  5. function kget(key){
  6. console.log(key);
  7. return window.localStorage.getItem(key);
  8. }
  9. function kremove(key){
  10. window.localStorage.removeItem(key);
  11. }
  12. function kclear(){
  13. window.localStorage.clear();
  14. }
  15. //测试更新方法
  16. function kupdate(key,value){
  17. window.localStorage.removeItem(key);
  18. window.localStorage.setItem(key, value);
  19. }

举例如下:

简单封装如下:

  1. //临时存储
  2. var TempCache = {
  3. cache:function(value){
  4. localStorage.setItem("EasyWayTempCache",value);
  5. },
  6. getCache:function(){
  7. return  localStorage.getItem("EasyWayTempCache");
  8. },
  9. setItem:function(key,value){
  10. localStorage.setItem(key,value);
  11. },
  12. getItem:function(key){
  13. return localStorage.getItem(key);
  14. },
  15. removeItem:function(key){
  16. return localStorage.removeItem(key);
  17. }
  18. };

在A页面的内容:

绑定所有workorderclass样式的div

设置相关的页面参数:

  1. //绑定视图的列表的相关的信息
  2. function bindListView(changeData){
  3. $(".workorderclass").each(function(){
  4. $(this).click(function(){
  5. //绑定订单的编号,便于在下一个页面切换时候使用
  6. TempCache.setItem("order_function_mgr_id",$(this).attr("id"));
  7. TempCache.setItem("order_function","serviceOrderFunction");
  8. TempCache.setItem("order_function_mgr_id_w",$(this).attr("id"));
  9. });
  10. });
  11. }

在页面B的初始化方法中:

使用并适时清空页面的storage、。

  1. //工单展示的初始化信息
  2. function displayWorkOrder(){
  3. //绑定订单的编号,便于在下一个页面切换时候使用
  4. var workOrderId=TempCache.getItem("order_function_mgr_id");
  5. workOrderId=workOrderId.replace(/(^\s*)|(\s*$)/g,"");
  6. //追踪工单来源
  7. functionName=TempCache.getItem("order_function");
  8. functionName=functionName.replace(/(^\s*)|(\s*$)/g,"");
  9. if(workOrderId!=''){
  10. queryWorkOrderInfo(workOrderId,functionName);
  11. TempCache.removeItem("order_function_mgr_id");       }else{
  12. alert("服务请求失败,请稍候再试....");
  13. }
  14. }

如有不懂的地方,欢迎沟通谢谢!

JQueryMobile页面跳转参数的传递解决方案的更多相关文章

  1. Android first --- 页面跳转及数据传递

    页面跳转即数据传递 创建第二个界面Acivity *需要在清单文件中添加配置一个Actuvity标签 标签中如果带有这个子节点,则会在Android中添加一个快捷图标 <intent-filte ...

  2. 微信小程序 页面跳转navigator与传递参数

    页面之间跳转使用 navigator标签,wx.navigateTo ,wx.redirectTo 1.URL就是跳转的页面路径.上面代码中就是navigator目录下的navigator页面,tit ...

  3. angular4 在页面跳转的时候传递多个参数到新页面

    页面跳转 router.navigate //单一参数: this.router.navigate(['/detail',id]); //多个参数: this.router.navigate(['/d ...

  4. jquerymobile页面跳转和参数传递

    http://blog.csdn.net/chen052210123/article/details/7481578 页面跳转: 页面跳转时pagebeforechange事件会被触发两次,通过$(d ...

  5. iOS页面跳转及数据传递

    转: http://blog.csdn.net/wang9834664/article/details/8025571 iOS页面跳转: 第一种 [self.navigationController  ...

  6. Android应用开发基础之六:页面跳转和数据传递

    创建第二个Activity 需要在清单文件中为其配置一个activity标签 标签中如果带有这个子节点,则会在系统中多创建一个快捷图标 <intent-filter> <action ...

  7. android 学习随笔十四(页面跳转与数据传递)

    1.activity 创建第二个Activity 需要在清单文件中为其配置一个activity标签 标签中如果带有这个子节点,则会在系统中多创建一个快捷图标 <intent-filter> ...

  8. Android初级教程理论知识(第五章页面跳转和数据传递)

    总体概述: Android四大组件 Activity BroadCastReceiver Service ContentProvider 创建第二个activity 新创建的activity,必须在清 ...

  9. struts2 action 页面与action参数的传递的三种方式

    第一种: 初始页面: <form action="LoginAction.action" method="post"> 用户名:<input ...

随机推荐

  1. ylb:SQL 常用函数

    ylbtech-SQL Server: SQL Server-SQL 常用函数 1,数学函数 2,日期和时间函数 3,字符串函数 4,转换函数 1,ylb:SQL 常用函数返回顶部 1,数学函数 2, ...

  2. 使用maven在netbeans下构建wicket项目

    在netbeans下构建wicket项目,网上流传较多的方法是直接使用netbeans的wicket插件,这种方法虽然简单,但是依赖的wicket版本较老,更新较慢,并且很容易与其他第三方库不兼容.使 ...

  3. 八皇后问题 --- 递归解法 --- java代码

    八皇后问题是一个以国际象棋为背景的问题:如何能够在 8×8 的国际象棋棋盘上放置八个皇后,使得任何一个皇后都无法直接吃掉其他的皇后?为了达到此目的,任两个皇后都不能处于同一条横行.纵行或斜线上.八皇后 ...

  4. AC多模式匹配算法

    建议:学习ac算法最好的途径是看论文pdf_Efficient_String_Matching_An_Aid_to_Biblio 一.一般的搜索算法 keyword: { he, she, his, ...

  5. Linux/Unix mac 命令笔记

    bg和fg Linux/Unix 区别于微软平台最大的优点就是真正的多用户,多任务.因此在任务管理上也有别具特色的管理思想.我们知道,在 Windows 上面,我们要么让一个程序作为服务在后台一直运行 ...

  6. nova service-list

    nova-scheduler start/running, process 4820root@ruiy-controller-a:/var/log/nova# nova service-list+-- ...

  7. QueryInterface

    QueryInterface IUnknown *p2; hr = pInnerUnknown->QueryInterface(vGUID2, (void**)&p2); IUnknow ...

  8. Terrain & Light & Camera

    [Terrain Engine] 1.When you press F, wherever your mouse is positioned will be moved to the center o ...

  9. cvc-elt.1: Cannot find the declaration of element 'beans'

    @(编程) 现象描述 导入的一个eclipse项目报错,各种方法都无法解决,报错信息如下: cvc-elt.1: Cannot find the declaration of element 'bea ...

  10. oracle 的行级触发器

    create or replace trigger tri_insertAcceptList after insert on STDOC.DEVELOPER for each row DECLARE ...