Correct radio change events and optimize CollectionBinder::getManagerForModel #133

Merged
merged 4 commits into from Apr 29, 2013
@@ -71,17 +71,7 @@
},
getManagerForModel: function(model){
- var i, elManager, elManagers = _.values(this._elManagers);
-
- for(i = 0; i < elManagers.length; i++){
- elManager = elManagers[i];
-
- if(elManager.getModel() === model){
- return elManager;
- }
- }
-
- return undefined;
+ return this._elManagers[_.isObject(model)? model.cid : model];
},
_onCollectionAdd: function(model){

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -407,19 +407,19 @@
switch (el.attr('type')) {
case 'radio':
if (el.val() === convertedValue) {
+ // must defer the change trigger or the change will actually fire with the old value
+ el.prop('checked') || _.defer(function() { el.trigger('change'); });
el.prop('checked', true);
}
else {
+ // must defer the change trigger or the change will actually fire with the old value
el.prop('checked', false);
}
break;
case 'checkbox':
- if (convertedValue) {
- el.prop('checked', true);
- }
- else {
- el.prop('checked', false);
- }
+ // must defer the change trigger or the change will actually fire with the old value
+ el.prop('checked') === !!convertedValue || _.defer(function() { el.trigger('change') });
+ el.prop('checked', !!convertedValue);
break;
case 'file':
break;
Oops, something went wrong.