Using bootstrap-modal as Backbone.js view

Allright, so the solution is was rather simple: App.Views.ProjectsNav ||= {} class App.Views.ProjectsNav.NewProjectView extends Backbone.View tagName: ‘div’ events: { ‘click .save’: ‘save’, ‘click .cancel’: ‘hide’, ‘hidden’: ‘hidden’, ‘shown’: ‘shown’ } initialize: (options) -> super(options) @collection = options.collection hide: () -> @el.modal(true).hide() false save: (e) -> … @model.save(attrs, { success: (project) => @model = project @collection.add(@model) … Read more

Why use the javascript function wrapper (added in coffeescript) “.call(this)”

It’s a way to make sure that the compiled CoffeeScript has its own scope for variable names. This has benefits in terms of efficiency and simplicity (you know you the generated JavaScript won’t stomp on variables used by other code). You can disable it with the –bare (or -b) option to the CoffeeScript compiler. The … Read more

Cannot call ‘start’ of undefined when starting backbone.js history.

Do you have any routes on the controller? Backbone only creates the history once at least one route is specified. More: TypeError: Cannot call method ‘start’ of undefined** Hmm, for some reason Backbone.history is undefined, and so there is no start method on it. It turns out that Backbone.js creates an instance of Backbone.History (upper … Read more

CoffeeScript editor for MacOS

On http://jashkenas.github.com/coffee-script/ there is a list of what is available. For Emacs there is CoffeeScript Major Mode (Emacs for mac: http://aquamacs.org/) For Vim there is Vim CoffeeScript (Vim for mac: http://code.google.com/p/macvim/) For Textmate there is CoffeeScript TextMate Bundle (how noted by Trevor, this is maintained by CoffeeScript creator Jeremy Ashkenas. And how noted by Chocohound, … Read more

Multiple Files communication with coffeescript

Depending on whether this is client- or server-side code, there are two slightly different approaches. Client-side: Here we attach things that should be available across files to the global namespace (window) as follows: class window.ChatService constructor: (@io) -> Then, in another file both ChatService and window.ChatService will allow access to the class. Server-side: Here we … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)