I checked firebug and found that readOnly == false when it should be even though the TW is not editable. This makes me think that the asynchronous nature of Ajax calls causes readOnly to be correctly set after the TW has initialized but because TW does not have a handler to update itself the expected effect does not happen. Is there a way to prevent editing after TW has initialized?
On Mar 12, 8:17 pm, gkdev <[email protected]> wrote: > Hi Mario, > > I tried with a vanilla TW and have the same problem (I don't have any > plugins that change readOnly). I also tried using displayMessage but > it gives me exactly the same information as alert(). If I comment out > my code readOnly defaults to true. I looked at the TW source code and > found that chkHttpReadOnly is set to true inside a script called > jsArea but I could not find any documentation for this online. Still > not sure what to do. > > --Ilya > > On Mar 12, 8:41 am, PMario <[email protected]> wrote: > > > Hi, > > Have you tried your plugin with a vanilla TW? > > If you use a customized version may be readOnly is set somewhere else > > again. > > > Have you tried displayMessage() instead of alert(). > > Or console.log() if available. > > > What is, if data is not equal to value1 nor to value2? > > > regards Mario > > > On Mar 12, 1:34 pm, gkdev <[email protected]> wrote: > > > > Hi, > > > I'm a new tiddlywiki user and developer trying to write my first > > > plugin. I'm serving the tiddlywiki over http and the plugin needs to > > > fetch a value from the server which if it is equal to "value1" causes > > > the plugin to set readOnly = true and if it is equal to "value2" > > > causes readOnly = false. The plugin makes the server call as soon as > > > the tiddlywiki is loaded and receives the data correctly, but for some > > > reason readOnly is not set correctly. The code is below: > > > > //this is the callback function from the Ajax call: > > > function processServerData(data) { > > > alert(data); //this returns the correct value > > > if(data == "value1") { > > > //put tiddlywiki in read-only mode: > > > readOnly = true; > > > } > > > if(data == "value2") { > > > readOnly = false; > > > } > > > alert(readOnly); //does NOT return correct value based on the > > > above if statements > > > > } > > > > I keep on getting that readOnly == true which is very strange. By the > > > way, I have config.options.chkHttpReadOnly = false; > > > Can anyone help? -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/tiddlywikidev?hl=en.
