We have a requirement where we need to make all the form input elements as readonly
when user access is set as "READ ONLY".
We are using a widget based template approach in our coding, where the widgets are specified in the template HTML and that are used in the corresponding JS file.
I have tried with the following code in my JS postcreate
method :
var item=dojo.query("#showtech_log_title_pane"); // id of the content pane
for (var i=0;i{
dijit.byId(item[i]).set('readOnly',true);
}
Error : dijit by id-> undefined or null
also,
var container = dojo.query("#showtech_log_title_pane");
dojo.query('input', container).forEach(
function(inputElem){
inputElem.disabled = 'disabled';
}
)
Error: Create Element not a method
To disable a widget you have to get a reference to it , and set its disabled attribute to true.
In your case, you have to iterate through all inputs that have ids ( to be sure that's a created widget ) then get enclosing widget of input and set it to disabled
Below a working example :
Here is also a fiddle