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