A more object oriented solution:
define( [ "dojo/_base/declare", "dijit/form/Form", "dijit/form/Textarea", "dijit/form/Button" ], function(declare, Form, TextArea, Button) { return declare( "mypackage.MyForm", Form, { textarea: new TextArea({}), submitButton: new Button({ type: "submit", label: "ready!" }), constructor: function(args) { declare.safeMixin(this, args); }, onSubmit: function() { alert(this.textarea.get('value')); }, postCreate: function() { this.domNode.appendChild( this.textarea.domNode ); this.domNode.appendChild( this.submitButton.domNode ); } }); } );
Just release new mypackage.MyForm({}) anywhere you can expect a widget.
jglatre
source share