【问题标题】:JQuery Mobile Page AliasesJQuery 移动页面别名
【发布时间】:2013-07-18 14:52:24
【问题描述】:

是否可以在 JQuery Mobile 中为页面添加别名,以便对任一名称的哈希更改都会导致页面显示?

背景
大家好,我正在制作一个 MVC 风格的 JQuery Mobile 应用程序,其中每个页面都有自己的 JavaScript 控制器。然后在 JQMs PageBeforeShow 事件上,相关控制器在显示之前使用 Mustache 模板呈现页面。

在我的应用程序中,文档正文中有三个 JQM 页面容器,如下所示:

<div data-role='page' id='profile'></div>
<div data-role='page' id='editprofile'></div>
<div data-role='page' id='register'></div>

这些页面都使用相同的控制器和 mustache 模板,因为它们的内容非常相似,但这显然会在您访问每个页面后创建大量重复的内容。

我更喜欢在哈希更改为#profile#editprofile#register 时加载的单个JQM 页面。

有谁知道 JQuery Mobile 是否支持此功能或是否有可行的解决方法?

谢谢

【问题讨论】:

    标签: jquery jquery-mobile alias mustache


    【解决方案1】:

    您可以使用changePage转换到page id指定的页面。

    $.mobile.changePage ('#profile');
    $.mobile.changePage ('#editprofile');
    $.mobile.changePage ('#register');
    

    【讨论】:

      猜你喜欢
      • 2013-09-09
      • 1970-01-01
      • 2012-04-02
      • 2011-08-04
      • 2012-02-14
      • 2012-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多