Created
September 7, 2011 15:48
-
-
Save scottb/1200943 to your computer and use it in GitHub Desktop.
Getting Dojo to work with Rails 3.1 and Sprockets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= require_directory . | |
dojo.require('dojox.rails'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hellodojo</title> | |
<%= stylesheet_link_tag 'http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css' %> | |
<%= stylesheet_link_tag 'application' %> | |
<%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js', :'data-dojo-config' => %Q(dojoBlankHtmlUrl:'/blank.html', baseUrl: 'assets/', modulePaths: {custom: 'custom'}) %> | |
<%= javascript_include_tag 'application' %> | |
<%= csrf_meta_tags %> | |
</head> | |
<body class='claro'> | |
<%= yield %> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dojo modules then go under app/assets/custom -- may be written in Coffeescript, if desired. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At the end of the first javacript_include_tag, it configures Dojo's modulePaths. In the example, it tells it to find modules starting with "custom" under the path "custom". So, if you create a module, say "custom.test", and put it app/assets/javascripts/custom/test.js, you'd load it with: dojo.require( "custom.test");
You can change the modulePaths in the include to be whatever you need for your particular modules.