Rails: support rails on rails gem-
Trying to follow along with Ryan Bates's Backbone.js tutorial to create a lottery app, but I already ran into problems with the first bit of code. In the init function of the application.js application, it has initialized a new instance of Raffler routes, which should raise the Home Page warning, but I am getting the following errors in Firebug which I don't understand.
entries.js:5Uncaught ReferenceError: Raffler is not defined
entry.js:15Uncaught ReferenceError: Backbone is not defined
entries.js:23Uncaught ReferenceError: Backbone is not defined
index.js:17Uncaught ReferenceError: Backbone is not defined
application.js:7Uncaught SyntaxError: Invalid regular expression: missing /
raffler.js:9Uncaught TypeError: undefined is not a function
Any ideas how I can fix this?
JavaScripts / raffler / application.js
window.Raffler =
Models: {}
Collections: {}
Views: {}
Routers: {}
init: ->
new Raffler.Routers.Entries()
Backbone.history.start()
$(document).ready ->
Raffler.init()
routers /entries.js
class Raffler.Routers.Entries extends Backbone.Router
routes:
'': 'index'
index: ->
alert "home page"
Update
After starting the generator, it //= require_tree .
was right after the jquery_ujs request, which I found (I think) caused some of the problems. However, I have now moved it to the bottom and am still getting this error.
Raffler.Routers.Entries is not a constructor
[Break On This Error]
new Raffler.Routers.Entries();
application.js
//= require jquery
//= require jquery_ujs
//= require underscore
//= require backbone
//
//= require .//raffler
//
//= require_tree ../templates/
//= require_tree .//models
//= require_tree .//collections
//= require_tree .//views
//= require_tree .//routers
//= require_tree .
source to share
I found someone else who had the same problem and then made it work. I copied his code (which was exactly the same as mine) into my file and now I'm working. I do not know why
window.Raffler =
Models: {}
Collections: {}
Views: {}
Routers: {}
init: ->
new Raffler.Routers.Entries()
Backbone.history.start()
$(document).ready ->
Raffler.init()
source to share