0

It says here(http://ace.c9.io/#nav=embedding) just copy one of src* subdirectories somewhere into your project I have put it in mykeystoneapp/public/js(my default home is mykeystoneapp/public)

Here are the errors I get:

1.Uncaught TypeError: $.cookie is not a function(ui.js:8)

2.Uncaught Error: Missed anonymous define() module: function …(require.js:141) http://requirejs.org/docs/errors.html#mismatch

Here is my Jade code:

script(src='/js/ace/demo/kitchen-sink/require.js')
script.
  require.config({paths: {ace: "/js/ace/build/src"}});
  define('testace', ['ace/ace'],
  function(ace, langtools) {
    console.log("This is the testace module");
    var editor = ace.edit("editor_container");
    editor.setTheme('eclipse');
    editor.session.setMode('javascript');
    require(["/js/ace/lib/ace/requirejs/text!src/ace"], function(e){
      editor.setValue(e);
    })
  });
  require(['testace']);

Secondly if I put debugger in EventEmitter(https://github.com/ajaxorg/ace-builds/blob/master/src/ace.js#L3300) I can see it’s properly reaching EventEmitter._dispatchEvent with eventName=‘changeMode’ but it returns without any operation as there are no !listeners or defaultHandler

Johnny Willemsen
  • 2,942
  • 1
  • 14
  • 16
ishandutta2007
  • 16,676
  • 16
  • 93
  • 129

1 Answers1

0

editor.session.setMode('javascript'); is wrong, it should be editor.session.setMode('ace/mode/javascript'); instead. Same for theme which is supposed to be ace/theme/eclipse.

error in ui.js is not related to ace, since ace doesn't have a file named ui.

a user
  • 23,300
  • 6
  • 58
  • 90
  • That doesn't change anything, it's still listeners = [] and defaultHandler=undefined. In fact I tried all possible combinations of paths before posting the question. It's true require.js and ui.errors may not be part of ace, but the error goes away once I comment out requirejs and ace calls. – ishandutta2007 Jun 01 '15 at 22:23
  • I think, listeners = [] and defaultHandler=undefined is normal, i can help you debug it, if you can give me a link to online demo. – a user Jun 02 '15 at 05:44
  • The script you are loading isn't ace.js but a modified version of it, on line 3283 there is an undefined variable `eventName` – a user Jun 13 '15 at 17:03
  • sorry for the unclean code. reverted all the experimental changes, now you can have a look – ishandutta2007 Jun 14 '15 at 17:39
  • are you using ace 0.1 now? please use the latest version from https://github.com/ajaxorg/ace-builds/blob/master/src/ace.js also why do you load require.js? it is not needed for using ace. – a user Jun 15 '15 at 12:20
  • Isn't require.config({paths: {ace: "/js/ace/build/src"}}); calling it ? – ishandutta2007 Jun 15 '15 at 17:21
  • it does, but why you call that if you are using prebuilt version anyway? – a user Jun 15 '15 at 20:34
  • I see, now I get it. My questions may sound pretty naive since I am a beginner so please bear with it for now, so what are the pros and cons of using a prebuild version against library version? And how would the code for each case look like? – ishandutta2007 Jun 16 '15 at 02:22
  • Here is the link to the repo I am trying to integrate ace with, in case you need to checkout to demonstate.thanks. github.com/ishandutta2007/test – ishandutta2007 Jun 16 '15 at 02:22
  • see https://github.com/ajaxorg/ace-builds/blob/v1.1.9/demo/autoresize.html#L30-L53 and https://github.com/ajaxorg/ace/blob/v1.1.9/demo/autoresize.html#L30-L63 if you already use requirejs and have a build step for requirejs modules, you can use library version, otherwise use pre built version – a user Jun 16 '15 at 12:02
  • tried . doesnt work. Infact I started from this example only. please check my updated push once, stuck on this for a long time. – ishandutta2007 Jun 16 '15 at 14:59
  • tried what? i don't see any updates on http://52.26.122.114:3000/editor it still have a version with ancient ace. – a user Jun 16 '15 at 18:52
  • ancient as in ? github.com/ajaxorg/ace-builds/blob/master/src/ace.js is the ace used and now calls look like this var editor1 = ace.edit("editor_container"); editor1.setTheme('ace/theme/twilight'); editor1.session.setMode('ace/mode/javascript'); – ishandutta2007 Jun 16 '15 at 23:58
  • and did you check the error ? Its now "Uncaught TypeError: Cannot read property 'cssText' of null" – ishandutta2007 Jun 17 '15 at 00:11
  • ancient as in https://github.com/ajaxorg/ace/blob/v0.2.0/build/src/ace.js that is very old. https://github.com/ajaxorg/ace-builds/blob/master/src/ace.js and http://52.26.122.114:3000/js/ace/build/src/ace.js are not the same – a user Jun 17 '15 at 08:29
  • Thanks a lot, you should have told that at the outset, I wasted so much time banging my head over those errors. I didn't ever notice that I was using a 4 year old repo.Thanks anyways :-) – ishandutta2007 Jun 17 '15 at 23:49
  • well i told you that you are using ace 0.1 once you showed me your code, but you were too focused on cssText error ;) – a user Jun 18 '15 at 02:44
  • Hey a user a quick question, after I started working with ace once I started exploring for inspirations, I found that very few sites actually use ACE editor, almost all I know of use codemirror. Any idea why is it so ? – ishandutta2007 Jul 23 '15 at 01:33
  • I guess it's mainly because Codemirror has better documentation and may be easier to get started with. – a user Jul 23 '15 at 13:06
  • Initially I was suspecting license may be the reason then I found both are MIT Licensed , then I though maybe performance is an issue for ace but googled a lot, as of now even that don't seem to be the reason, lets wait until I test it out myself – ishandutta2007 Jul 24 '15 at 15:10
  • ACE is BSD Codemirror is MIT – ishandutta2007 Jul 29 '15 at 16:49
  • Do you think that is the reason for the difference? Both of those are very permissive licences, so i'd expect it to not play a big role. – a user Jul 29 '15 at 19:57