View navigation history management Authors: Yoshiroh Kamiyama
The bookmarkable feature
In Dojo Mobile 1.8,the bookmarkable function has been enhanced to be able to manage the state of multiple views. The bookmarkable feature is enabled if you require the module dojox/mobile/bookmarkable. When you make a view transition,dojox/mobile/bookmarkable searches for all the selected views in the page,and sets a new fragment id that consists of a comma-separated list of the found views (ex. #page2,bar3,view0) to the browser’s current URL. When you move back to this page,dojox/mobile/bookmarkable sees the list of selected views and restores the selected state. Note that ‘selected’ does not necessarily mean the view is ‘visible’. For example,there may be a currently hidden view that has child views. One of the child views is ‘selected’,but it is not ‘visible’ since its parent is currently hidden. Sibling views always have one and only one selected view.
Example:
<script>
require([
"dojox/mobile",
"dojox/mobile/bookmarkable",
....
]);
</script>
<div id="home" data-dojo-type="dojox/mobile/View">
<ul data-dojo-type="dojox/mobile/RoundRectList">
<li data-dojo-type="dojox/mobile/ListItem" data-dojo-props='moveto:"#page1"'>
Go to page 1
</li>
<li data-dojo-type="dojox/mobile/ListItem" data-dojo-props='moveto:"#page2"'>
Go to page 2
</li>
</ul>
</div>
The bookmarkable feature should be able to handle cases where views are nested or split. However,it cannot support dynamic views created by ListItem and other _ItemBase-based item’s ‘url’ property. Even if the created view’s IDs are pushed to the browser URL’s fragment id,dojox/mobile/bookmarkable can never kNow the URL of the external content from its view id.
If you set mblForceBookmarkable:true to dojoConfig or data-dojo-config,and require dojox/mobile/bookmarkable,all the view transitions are stored in the browser history regardless of whether the value of ‘moveto’ has the ‘#’ prefix or not. In this case,you can omit the ‘#’ prefix as shown in the example below.
<script src=\'#\'" /dojo.js" data-dojo-config="...,mblForceBookmarkable: true"></script>
<script>
require([
"dojox/mobile",
....
]);
</script>
<div id="home" data-dojo-type="dojox/mobile/View">
<ul data-dojo-type="dojox/mobile/RoundRectList">
<li data-dojo-type="dojox/mobile/ListItem" data-dojo-props='moveto:"page1"'>
Go to page 1
</li>
<li data-dojo-type="dojox/mobile/ListItem" data-dojo-props='moveto:"page2"'>
Go to page 2
</li>
</ul>
</div>
转自:http://dojotoolkit.org/reference-guide/1.9/dojox/mobile/bookmarkable.html#dojox-mobile-bookmarkable
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。