Reputation: 731
When I am doing the validation at client side for one of my application. I got these questions in my mind.
Question1 : what is the difference between dijit.byId('someId').value and dijit.byId('someId').get('value')
Question2:
for(indx in strg){
comment+=strg[indx].replace(/([^\x00-\x7E]|\\s*\\n)*$/g, '');
}
In the above js snippet, I got the following error in Browser console
replace is not a function
Can you please help me someone to solve this
Thanks.
Upvotes: 2
Views: 336
Reputation: 73938
Answering your first part of you question.
dijit.byId('id'); has been deprecated, you should use dijit/registry::byId()
instead.
registry.byId()
will return a widget with same ID if found.
You can use it in your application in this way:
require(["dijit/registry"], function(registry){
var widget = registry.byId("yourId");
});
You can read a property for a widget using widget.get('nameProperty')
, example:
require(["dijit/registry"], function(registry){
var widget = registry.byId("yourId");
var widgetValue = widget.get('value');
});
Generally accessing properties of your widget should be done using "getter" and "setter". Dojo offer two dedicated functions for that:
Getter:
widget.get('nameProperty');
Setter:
widget.get('nameProperty', 'newValue');
When using getter and setter you allow dojo to be aware of those operations, for example when using a setter, dojo events fire properly (like onChange for your widget).
In case you access/set a property directly on the widget you bypass dojo, missing is framework plumbing.
More information: https://dojotoolkit.org/reference-guide/1.10/dijit/registry.html
Upvotes: 3