arturadib/agility — Issue #60: Original model not updated
Author: ole108
Created: 2011-12-06 16:28:44+00:00
State: open

I would like agility to update the original model object I give to the factory function '$$()'.
This helps especially with big trees of agility components (e.g. Tables with hundreds of components).
*I would like to have only one source of truth for the model.*
I made a patch that takes the original model object instead of doing '$.extend(...)' and and throws an exception if the new model is non-empty and the model inherited from the prototype is non-empty too.
This works great for me and should save some memory at runtime.
Of course this behaviour is undesired for views and controllers.

Here is my Test-HTML:

var globalModel = { value: 'bla' };
var input = $$(globalModel,
'

value:

', {
'create': function() {
// put the original value somwhere visible
$('#message').append(globalModel.value);
},
'change:value': function() {
// put the original value again
$('#message').empty().append(globalModel.value);
// show the original value and the value from this.model
alert('global value: ' + globalModel.value + ', input.value: ' + this.model.get('value'));
}
}
);

$$.document.append(input, '#form');

Of course I would be willing to provide my patch (its quite small with two additional util functions).
But of course I am unsure if you like such a thing at all.
But for me its a plain bug since the view isn't bound to the model I provided.