I have a simple Backbone.js model:
class Avia.Student extends Backbone.Model
Told you it was simple :-) Anyhow, I'm saving it in the following view (snipped for clarity):
class Avia.StudentView extends Backbone.View
render: =>
html = JST['views/student_view_template'](model: @model)
@el.html(html)
Backbone.ModelBinding.bind(@)
$('#save').bind('click', @save)
save: (e) =>
e.preventDefault()
@model.save(
success: =>,
error: =>
)
When I click the save button, @save() is called, but fails with the following error (again, snipped for clarity as obviously it continues for a long time):
Uncaught RangeError: Maximum call stack size exceeded
Backbone.Events.trigger:117
_.extend._onModelEvent:635
Backbone.Events.trigger:117
_.extend._onModelEvent:635
Backbone.Events.trigger:117
_.extend._onModelEvent:635
Backbone.Events.trigger:117
Could someone please tell me what I'm doing wrong? I don't understand why this is happening ...
#savean element within@el? Are you sure? Because if it's elsewhere, then you're binding anotherclickevent to it on each render...Backbone.ModelBinding.bind(@)and ensured#saveis unique by renaming it to#woobleand renaming the associated bindings. I'm still encountering the same problem :-/backbone.jsfrom GitHub, and the problem persists.