Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative paths + Require.JS #852

Closed
fertapric opened this issue Jul 18, 2012 · 4 comments
Closed

Relative paths + Require.JS #852

fertapric opened this issue Jul 18, 2012 · 4 comments

Comments

@fertapric
Copy link

Hi all,
first of all, thanks for developing Ace, it's really useful. I'm having some issues getting Ace work with require.js.

The "entry point" of my application is:

<script data-main="/js/config/bootstrap.js" src="/js/libs/require/require.js"></script>

js/config/bootstrap.js

require.config({

  paths: {
    // LIBRARIES
    jquery: '../libs/jquery/jquery-loader',
    underscore: '../libs/underscore/underscore-loader',
    backbone: '../libs/backbone/backbone-loader',
    mustache: '../libs/mustache/mustache',
    ace: '../libs/ace/ace',

The project structure is:

+ js
    + config
        - bootstrap.js
    + libs
        + jquery
        ...
        + ace
           - ace-loader.js
           + ace <- all the ace lib: https://github.com/ajaxorg/ace/tree/master/lib/ace
                - ace.js

How could I load the ace editor, something like:

define([
  'jquery',
  'underscore',
  'backbone',
  'mustache',
  'ace'
], function(
  $,
  _,
  Backbone,
  Mustache,
  ace
) {

  /**
   * VIEW
   */
  var view = Backbone.View.extend({

    root: "#content-view",

    initialize: function() {
      _.bindAll(this, 'render');
      this.render();
    },

    render: function() {
      var html = Mustache.render(template, this.data);
      $(this.root).html(html);
      this.data.editor = ace.edit("editor");

Any help?
Thanks in advance

@nightwing
Copy link
Member

in define call shouldn't ace point to ace.js if yes you need to use 'ace/ace' in define, otherwise this looks like it should work

@fertapric
Copy link
Author

Thanks, it works now.
To help others:

js/config/bootstrap.js

require.config({

  paths: {
    // LIBRARIES
    jquery: '../libs/jquery/jquery-loader',
    underscore: '../libs/underscore/underscore-loader',
    backbone: '../libs/backbone/backbone-loader',
    mustache: '../libs/mustache/mustache',
    ace: '../libs/ace/ace',

view

define([
  'jquery',
  'underscore',
  'backbone',
  'mustache',
  'ace/ace'
], function(
  $,
  _,
  Backbone,
  Mustache,
  ace
) {

  /**
   * VIEW
   */
  var view = Backbone.View.extend({

    root: "#content-view",

    initialize: function() {
      _.bindAll(this, 'render');
      this.render();
    },

    render: function() {
      var html = Mustache.render(template, this.data);
      $(this.root).html(html);
      this.data.editor = ace.edit("editor");

@ruanzy
Copy link

ruanzy commented Jan 17, 2017

its not work

@tangce05
Copy link

I am learning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants