Skip to content

Instantly share code, notes, and snippets.

@dbashford
Created April 3, 2014 19:24
Show Gist options
  • Save dbashford/9961065 to your computer and use it in GitHub Desktop.
Save dbashford/9961065 to your computer and use it in GitHub Desktop.

Call to require JS in index.html

<script src="/javascripts/vendor/requirejs/require.js" data-main="/javascripts/main.js"></script>

The data-main is main.js, code here:

require
  urlArgs: "b=#{(new Date()).getTime()}"
  paths:
    jquery: 'vendor/jquery/jquery'

The problem is that while this sets up requirejs configuration, it never actually kicks off any code from the app.

This is the generic main.coffee that mimosa new delivers, it comes from here

require
  urlArgs: "b=#{(new Date()).getTime()}"
  paths:
    jquery: 'vendor/jquery/jquery'
  , ['app/example-view']
  , (ExampleView) ->
    view = new ExampleView()
    view.render('body')

The require function takes multiple parameters. You are using one, that's the config object. The 2nd one here is an array, ['app/example-view'] that is the list of dependencies required to kick off the app. Once requirejs pulls in that dependency, it calls the callback, which is the 3rd param in the require call. This is where the app gets truly bootstrapped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment