1,
dateTextBox.onInput = function(e){
return false;
};
The user input is blocked, and the date control can also pop up
2,
dijit.form.TextBox.extend(
Editable: true,
_setReadOnlyAttr: function(/*Boolean*/ value){
domAttr.set(this .focusNode,’readOnly’, value || !this.editable);
this._set(“readOnly”, value);
},
_setEditableAttr: function(value){
this._set(“editable”, !!value);
domAttr.set(this.textbox, “readonly”, (this.readOnly || !value));
}
);
declare is to create a new class, and extend is to directly extend the base class. The advantage of this is that other classes based on this class can also be used. For example, after TextBox.extend, those Date, Time, ValidationTextBox do not need to be changed
3,
define([
“dojo/_base/declare”,
“dijit/form/DateTextBox”
], function(declare, DateTextBox){
return declare([DateTextBox], {
startup : function(){
this.inherited(arguments);
this.textbox.readOnly=true;
},
_setReadOnlyAttr: function(value){
this.set(“readOnly”, value);
}
})
});
4、
require([‘dojo/_base/lang’,’dijit/form/DateTextBox’,’dojo/ready’,’dojo/parser’ ], function(lang, DateTextBox, r eady, parser) {lang.extend(DateTextBox, {} startup: function(){} this.textbox.readOnly=true; }, _setReadOnlyAttr: function(value){}}}}} this.set(“readOnly”), value); ready(function(){ parser.parse().then(function(){ }); }); });