How to use dojo tools with rails 3.1 asset conveyor and coffee shop?

I am trying to use dojo-toolkit as a JS framework in rails 3.1 application, but I am struggling to include the structure of the required dojo structure with the required asterisks and coffeescript. Dojo seems to be expecting JS files on disk, but I think they are created on the fly from coffeescript.

I wonder if anyone can understand how the two requirements can coexist.

+5
source share
1 answer

I recently had to install dojo with 3.1 rails and an asset pipeline. Here are the steps I took to get it working:

1 / Enable Dojo

dojo SDK //javascripts, dojo, dijit dojox. :

= javascript_include_tag "dojo/dojo", :'data-dojo-config' => %Q(baseUrl: '/assets/dojo/', modulePaths: {modules: '/assets/modules', widgets: '/assets/widgets'})

"/" !

Google CDN :

script var djConfig = { baseUrl: '/assets/dojo/', modulePaths: {modules: '/assets/modules', widgets: 'widgets'} };
= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojo/dojo.xd.js"
script ="typeof(dojo) === \"undefined\" && document.write(unescape('%3Cscript src=\"#{asset_path('dojo/dojo')}\"%3E%3C/script%3E'));".html_safe

djConfig. dojo Google. - .


2/

"require" /assets/javascripts/application.js - ():

dojo.provide("myapp");

3/ dojo.require

djConfig 1/ modulePaths, , . , :

  • //JavaScripts//
  • //JavaScripts//

/test.js, :

dojo.require("modules.test");

4/ coffeescript ERB

erb, Rails.

, !

+7

All Articles