Yeoman Workflow and Integration with Backend Scripts

I like using this structure: rails-app/ –app/ –views/ –js/ –app/ –test/ –Gruntfile.js –public Here’s how I set it up: rails new rails-app cd rails-app/app/views mkdir js cd js yeoman init ember Then edit Gruntfile.js to change “output: ‘dist’” to “output: ‘../../../public’” After that, “yeoman build” or “yeoman build:dist” will output to the Rails /public folder. … Read more

Why is it considered bad practice to call trigger: true in the navigate function of backbone.js?

There seems to be some confusion about what Router#navigate does exactly, I think. Without any options set it will update the URL to the fragment provided. E.g. router.navigate(‘todo/4/edit’) will update the URL to #todo/4 AND will create a browser history entry for that URL. No route handlers are run. However, setting trigger:true will update the … Read more

Backbone.js history ‘on route change’ event?

There is the “route” event on the Router: http://backbonejs.org/#Events-catalog “route” (router, route, params) — Fired by history (or router) when any route has been matched. This allows you to bind to specific routes. If you want to fire a handler after any route, bind to “route”, and the route will be the first argument: myRouter.on(“route”, … Read more

Using the Backbone.js router to navigate through views modularized with require.js

In case anyone else is looking for a solution to this problem like I was, I’m posting what I ended up doing. If you’re using the boilerplate backbone.js, then you will have an initialize() function in router.js. I modified my initialize() function to look like the following: initialize = function () { var app_router; app_router … Read more

Backbone 1.1.0 Views – Reading Options

If you want to access to passed options – just save them: initialize: function (options) { this.options = options || {}; } If you use ES6: initialize (options = {}) { this.options = options; } If you want to save passed options for all Backbone.View‘s you can override constructor like ncksllvn suggested below.

Backbone.js Error Handling – how do you do it?

In my ears this sounds a bit on the complex side, at least to start with. Backbone.sync will already report errors that you can catch in your models .save() method: this.mymodel.save(/* … */, {success: function(model, result, xhr)…, error: function(model, xhr, options)…} (docs). If your serverside follows HTTP specs well, the error code is already provided … Read more

tech