Shubham
Shubham

Reputation: 187

How to use dojo moveTo programmatically through javascript?

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);
}

Upvotes: 2

Views: 2124

Answers (1)

MHeiss
MHeiss

Reputation: 107

This code sample registers an onclick event handler on a button with the id "ButtonID". After pressing the button, a lookup in the dijit registry will be performed to find the displayed view.

You can call the function performTransition(...) on any dojox.mobile.View.

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);
        });
});

But: Changing "moveTo" parameters programmatically is much more difficult than performing transitions between views. You have to do some nasty things to override the moveTo Attribute of a widget like for example a Backbutton in a dojox.mobile.Heading

var heading1 = dijit.registry.byId("ID_Heading");
heading1.destroyDescendants();
heading1.moveTo = viewId;
heading1.backButton = false;
heading1._setBackAttr("Zurück");            

Upvotes: 1

Related Questions