Having seen it in a couple of tutorials, I'm trying to execute the following line of code in my view
@model.on('change', @render, this)
Unfortunately the change event is not firing and therefore my view is not re-rendering.
I've tried binding to different events and creating a couple of custom events using the trigger function but nothing seems to be firing at all on the model. Furthermore, there are no errors coming from the console. The change event is working fine on a different collection. I'm using Zepto 1.0, Backbone.js 0.9.2 and Underscore.js 1.3.1
EDIT: I'm trying to execute the following from the Router
place: (id) ->
@model = new GM.Models.Place({id: "#{id}"})
@model.fetch
view = new GM.Views.Place(model: @model)
$('#container').html(view.render().el)
And my model is set up like this:
class GM.Models.Place extends Backbone.Model
urlRoot: '/mobile/place'
I am wondering if anyone has experienced similar problems before and has a quick fix. If not and you need more of the code to find an explanation please let me know...
.fetch()
does. Try it, as explained in @mu's answer. – bvulaj