I have multiple ace editors in my page. I have done so by replacing all the on the page to ace editor using the code below :
https://gist.github.com/duncansmart/5267653
I would like to set some of them editable and some of them readonly using 'setReadOnly' property of editor.
But when I use 'editor.setReadOnly(flag)' inside for loop, it changes the ReadOnly property of all ace editors.
If I do editor.getSession().setReadOnly(flag), I get an error
TypeError: undefined is not a function
In the above code, flag is either true or false. Any ideas on this?
I figured out the problem.
It value "true" passed as argument inside setReadOnly was fetched from textarea using 'get' function from domAttr(Dojo).
So the type of variable was a string.
I typecasted it to boolean using following code :
var editStringFlag=domAttr.get(textarea,'editFlag');
var editBoolFlag = (editStringFlag==='true')
editor.setReadOnly(editBoolFlag);
This resolved the issue