[#145,bugfix][s]: avoid generating an infinite loop in render event binding of fields widget (as occurred in certain cases).

This commit is contained in:
Rufus Pollock 2012-06-06 06:20:48 +01:00
parent 56a29c80a7
commit 63cb8a62b7

View File

@ -63,8 +63,12 @@ my.Fields = Backbone.View.extend({
this.el = $(this.el);
_.bindAll(this, 'render');
this.model.fields.bind('all', function() {
// TODO: this is quite restrictive in terms of when it is re-run
// e.g. a change in type will not trigger a re-run atm.
// being more liberal (e.g. binding to all) can lead to being called a lot (e.g. for change:width)
this.model.fields.bind('reset', function(action) {
self.model.fields.each(function(field) {
field.facets.unbind('all', self.render);
field.facets.bind('all', self.render);
});
// fields can get reset or changed in which case we need to recalculate