powmedia/backbone-forms

Nested List causes duplicate events on Add button

miketonks opened this issue · 1 comments

I'm using a list of NestedModel which contains a list.

// Model class for each ResourceSelector item
var FooSelectorModel = Backbone.Model.extend({
schema: {
name: 'Text',
tags: { type: 'List', itemType: 'Text' }
}
});

// Model class for each Rule item
var MyModel = Backbone.Model.extend({
defaults: {
},
schema: {
service: 'Text',
foo_selector: { type: 'List', itemType: 'NestedModel', model: FooSelectorModel }
}
});

All works really well except one thing. When I click 'Add' button on child list, it adds to both child and parent list.

We traced this down to the click event scope: 'click [data-action="add"]'

which although it's limited by DOM scope, the child node is inside the parent node, so event propagates to parent.

I will submit pull request with simple fix: event.stopPropagation();