Hi Shawn

Where does that error come from?  Is it the CodeMirror editor which is not
defined?

The API methods I expose from my Widget all guard against the CodeMirror
editor not being loaded; e.g. setValue & getValue will set and return a
private member if CM is not available, as do methods that would configure
CodeMirror (e.g. Add features/modes) and event handlers.

Are you able to put up your code in a repo somewhere, eg on github, so I can
take a look?

In my constructor, I call this.addListenerOnce("appear", this.__initEditor)
and then start loading CodeMirror's basic JS & CSS; __initEditor is called
from various places and is intended as "initialise the edit unless already
initialised, but if the scripts are not yet loaded then do nothing".

The code for __initEditor is below, but what probably makes mine different
is the dynamic loading of scripts ‹ the constructor adds a script (JS and
CSS) to be loaded asynchronously and in __initEditor if the scripts arent
loaded it will do nothing; other scripts can be added to the list by
enabling features & modes, so by the time that __initEditor is finally
called when all scripts are loaded, the DOM is

> __initEditor: function() {
>   if (this.__editor || // if already initialise do nothing
>       !this.__scriptsLoaded || // CodeMirror scripts not loaded?  Leave it
> until they are
>       !this.getContentElement().getDomElement()  // no DOM yet?  Try later
>       )
>     Return;
> 
>   // Make sure we have all the required init scripts loaded; the scripts are
> not
>   // yet loaded, then call __initEditor when they are
>   var scripts = this.__getInitScripts();
>   if (!grasshopper.af.ScriptLoader.isLoaded(scripts)) {
>     grasshopper.af.ScriptLoader.loadScript(scripts, this.__initEditor, this);
>     return;
>   }
> 
>   
>   var MODE = grasshopper.mce.CodeMirrorEditor.__MODES[this.getMode()],
>     dom = this.getContentElement().getDomElement(),
>     config = {
>       value: this.__pendingValue||"",
>       mode: MODE ? MODE.mode : this.getMode(),
>       theme: "default",//this.getTheme(),
>       lineNumbers: true,
>       onChange: qx.lang.Function.bind(this.__queueChangeEvent, this)
>     };
>   this.__pendingValue = null;
> 
>   // Start the editor
>   this.__editor = CodeMirror(dom, config);
>   // Set any features
>   for (var name in this.__features)
>   this.__applyFeature(name, this.__features[name]);
>   // resize
>   var elems = qx.bom.Selector.query(".CodeMirror-scroll");
>   for (var i = 0; i < elems.length; i++) {
>     elems[i].style.height = "100%";
>     elems[i].style.overflow = "scroll";
>   }
>   this.__resizeCodeMirror();
> },

John


On 15/08/2012 16:08, "smhanes" <[email protected]> wrote:

> John,
> 
> Thanks a ton for your response. It's definitely gotten me farther along.
> Luckily, I know which CM JS/CSS modules to load and can hard-code those in.
> 
> I can get the CM instance to load, but will occasionally get an uncaught
> referenceerror (editor is not defined).
> 
> Would it be too much trouble to get a peek at your initialization code? I'm
> actually still very, very, new to Qooxdoo and it's a lot to process.
> 
> Shawn
> 
> 
> 
> --
> View this message in context:
> http://qooxdoo.678.n2.nabble.com/Qooxdoo-2-0-1-and-CodeMirror-2-32-Integration
> -tp7580979p7580997.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
> 


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to