我有一个dojox.mobile站点,有一个共同的视图。我希望将视图重用为多个“按钮”,并调用一个函数,该函数将根据按下的按钮更改视图标题的标签。但是,当我更改innerHTML时,后退按钮就消失了。当我使用setattr函数时,标签不会改变。处理这件事的正确方法是什么?
</link> --> Demo This Problem <div id="MainMenu" data-dojo-type="dojox.mobile.View" data-dojo-props="selected: true" style="width: 100%; height: 100%;">
<h1 data-dojo-type="dojox.mobile.Heading">View A</h1>
<h2 dojoType="dojox.mobile.RoundRectCategory">Select a View</h2>
<ul data-dojo-type="dojox.mobile.RoundRectList">
<li data-dojo-type="dojox.mobile.ListItem" data-dojo-props="rightText:'Go!', moveTo: 'generic_view_x', callback:SetupViewA">
View A
</li>
<li data-dojo-type="dojox.mobile.ListItem" data-dojo-props="rightText:'Go!', moveTo: 'generic_view_x', callback:SetupViewB">
View B
</li>
</ul>
</div>
<div id="generic_view_x" data-dojo-type="dojox.mobile.View" style="width: 100%; height: 100%;">
<h1 id="view_x_header" data-dojo-type="dojox.mobile.Heading" data-dojo-props="back:'Main', moveTo:'MainMenu',label:'test'"></h1>
<div id="map_canvas" style="width: 100%; height: 100%;">
Some Other Stuff Here
</div>
</div>
<!-- configure and load dojo -->
<script src="./dojo/dojo.js" data-dojo-config="async:1, mblAlwaysHideAddressBar:true"></script>
<script>
require(["dojo"], function(dojo){
SetupViewA = function (){
// Doing it This way removes the back button
// document.getElementById('view_x_header').innerHTML = 'View A';
// This doesn't change anything
dojo.setAttr("view_x_header", 'label','View A')
}
SetupViewB = function (){
document.getElementById('view_x_header').innerHTML = 'View B';
}
})
require(["dojox/mobile/parser", "dojox/mobile", "dojox/mobile/deviceTheme", "dojox/mobile/compat", "dojo/domReady!"],
function(parser) {
parser.parse();
});
</script>
</body>
发布于 2013-12-19 14:30:42
对于小部件(如头),最好使用它的get/set来更改小部件的属性。
你应该使用:
dijit.registry.byId("view_x_header").set("label", "View B");小提琴::http://jsfiddle.net/theinnkeeper/Wgx8u/
https://stackoverflow.com/questions/20668078
复制相似问题