2

I can markup a Heading or ListItem to have a moveTo attribute and that transition works perfectly.

Is there a way perform a transition to a named view programmatically say, on a button click?

Somewhere on the net I found below code, but its not working. I need something similar to this -

function moveTo(){
var w = dijit.byId('currentView');
w.performTransition('#newView',1,"fade",null);
}
4

1 回答 1

1

此代码示例在 ID 为“ButtonID”的按钮上注册了 onclick 事件处理程序。按下按钮后,将在 dijit 注册表中进行查找以找到显示的视图。

您可以在任何 dojox.mobile.View 上调用函数 performTransition(...)。

require(["dijit/registry"], function(registry) {
    dojo.ready(function() {
        // Button Listener
        registry.byId("ButtonID").on("click", function(){
            var oldView = dijit.registry.byId("ID_View1");
            oldView.performTransition("ID_View2", 1, "slide", null);
        });
});

但是: 以编程方式更改“moveTo”参数比在视图之间执行转换要困难得多。您必须做一些讨厌的事情来覆盖小部件的 moveTo 属性,例如 dojox.mobile.Heading 中的 Backbutton

var heading1 = dijit.registry.byId("ID_Heading");
heading1.destroyDescendants();
heading1.moveTo = viewId;
heading1.backButton = false;
heading1._setBackAttr("Zurück");            
于 2013-02-18T15:32:58.627 回答