[483] | 1 | define([ |
---|
| 2 | "dojo/_base/declare", |
---|
| 3 | "dijit/_WidgetBase" |
---|
| 4 | ], function(declare, _WidgetBase){ |
---|
| 5 | return declare("dojox.mvc.Element", _WidgetBase, { |
---|
| 6 | // summary: |
---|
| 7 | // A widget implicitly created by dojox/mvc/parserExtension. |
---|
| 8 | // Maps "value" attribute to form element value, innerText/innerHTML to element's innerText/innerHTML, and other attributes to DOM attributes. |
---|
| 9 | // Also, for form element, updates value (or checked for check box) as user edits. |
---|
| 10 | |
---|
| 11 | _setInnerTextAttr: {node: "domNode", type: "innerText"}, |
---|
| 12 | _setInnerHTMLAttr: {node: "domNode", type: "innerHTML"}, |
---|
| 13 | |
---|
| 14 | buildRendering: function(){ |
---|
| 15 | // summary: |
---|
| 16 | // Set onchange event handler for form elements. |
---|
| 17 | |
---|
| 18 | this.inherited(arguments); |
---|
| 19 | if(/select|input|textarea/i.test(this.domNode.tagName)){ |
---|
| 20 | var _self = this, node = this.focusNode = this.domNode; |
---|
| 21 | this.on("change", function(e){ |
---|
| 22 | var attr = /^checkbox$/i.test(node.getAttribute("type")) ? "checked" : "value"; |
---|
| 23 | _self._set(attr, _self.get(attr)); |
---|
| 24 | }); |
---|
| 25 | } |
---|
| 26 | }, |
---|
| 27 | |
---|
| 28 | _getCheckedAttr: function(){ return this.domNode.checked; }, |
---|
| 29 | _getValueAttr: function(){ return this.domNode.value; } |
---|
| 30 | }); |
---|
| 31 | }); |
---|