Results 1 to 2 of 2
  1.    #1  
    I'm trying to use the code from UI Widgets to display a Dialog box with "Save" and "Cancel" side by side. In the example, the setup code is as follows:
    Code:
    MydialogAssistant.prototype.setup = function(widget) {
    	this.widget = widget;
    	/* this function is for setup tasks that have to happen when the scene is first created */		
    	/* use Mojo.View.render to render view templates and add them to the scene, if needed. */	
    	/* setup widgets here */	
    	/* add event handlers to listen to events from widgets */
    	d = new Date();
    	this.t_attr = {
    		label:	'Time',
    		modelProperty:	'value',
    		minuteInterval : 10
    	    };
    	this.t_model = {
    		value : d
    	}
    	this.controller.setupWidget('time_field', this.t_attr, this.t_model);
    	this.save = this.save.bindAsEventListener(this);
    	this.cancel = this.cancel.bindAsEventListener(this);
    	
    	Mojo.Event.listen(this.controller.get('save'),Mojo.Event.tap,this.save);
    	Mojo.Event.listen(this.controller.get('cancel'),Mojo.Event.tap,this.cancel);
    	
    }
    As you can see, the parameter "widget" is passed to the setup() function. The code that puts the dialog up is:
    Code:
    DialogAssistant.prototype.buttonPressed = function(){
    	this.controller.showDialog({
    			template: 'dialogs/dialog/mydialog-scene',
    			assistant: new MydialogAssistant(this, this.callback.bind(this)),
    			preventCancel: true
    		});
    }
    Where is "widget" passed to setup()? When I tried to do the same code in my code, I get:
    Error: Caught exception in _Dialog widget 'undefined' setup():

    Dazed and confused! Help?
  2.    #2  
    Sorry, the error was being caused by a typo. Somehow "widget" gets passed to setup() and everything is okay even though I don't understand how it works.

Posting Permissions