proxy.reset();
});
this._proxies = {};
+ _(this.records).invoke('unbind', null, this._onRecordEvent);
this.length = 0;
this.records = [];
this._byId = {};
* @returns this
*/
remove: function (record) {
- var self = this;
var index = _(this.records).indexOf(record);
if (index === -1) {
_(this._proxies).each(function (proxy) {
return this;
}
+ record.unbind(null, this._onRecordEvent);
this.records.splice(index, 1);
delete this._byId[record.get('id')];
this.length--;
equal(c.get(2), undefined);
strictEqual(c.at(1).get('value'), 20);
});
+ test('Remove unbind', function () {
+ var changed = false,
+ c = new openerp.web.list.Collection([ {id: 1, value: 5} ]);
+ c.bind('change', function () { changed = true; });
+ var record = c.get(1);
+ c.remove(record);
+ record.set('value', 42);
+ ok(!changed, 'removed records should not trigger events in their ' +
+ 'parent collection');
+ });
test('Reset', function () {
var event, obj, c = new openerp.web.list.Collection([
{id: 1, value: 5},
strictEqual(c.length, 1);
strictEqual(c.get(42).get('value'), 55);
});
+ test('Reset unbind', function () {
+ var changed = false,
+ c = new openerp.web.list.Collection([ {id: 1, value: 5} ]);
+ c.bind('change', function () { changed = true; });
+ var record = c.get(1);
+ c.reset();
+ record.set('value', 42);
+ ok(!changed, 'removed records should not trigger events in their ' +
+ 'parent collection');
+ });
test('Events propagation', function () {
var values = [];
<!-- jquery -->
<script src="/web/static/lib/jquery/jquery-1.6.4.js"></script>
<script src="/web/static/lib/jquery.ui/js/jquery-ui-1.8.9.custom.min.js"></script>
+ <script src="/web/static/lib/jquery.ba-bbq/jquery.ba-bbq.js"></script>
<script src="/web/static/lib/datejs/globalization/en-US.js"></script>
<script src="/web/static/lib/datejs/core.js"></script>