// server side
$.post( "http://localhost:5425/app/v1/present", data)
.done(function( representation ) {
$( "#representation" ).html( representation );
}
);
var actions = {} ;
actions.edit = function(data) {
data.lastEdited = {title: data.title, description: data.description, id: data.id } ;
present(data) ;
return false ;
} ;
actions.save = function(data) {
data.item = {title: data.title, description: data.description, id: data.id || null} ;
present(data) ;
return false ;
} ;
actions.delete = function(data) {
data = {deletedItemId: data.id} ;
present(data) ;
return false ;
} ;
actions.cancel = function(data) {
present(data) ;
return false ;
} ;
I want to change color (for example) of my view-component and I would like to select this component from DOM
You should not do that, the whole point of V = f(M) is that you (almost) never manipulate the DOM, the color should be part of the model and when you generate the stateRepresentation based on the new application state.
Hi. In the rocket launcher example, ¿What is the purpose of this line?
present = present || model.present ;
When i would want to pass a custom present function? in which cases?
Another question: It's a bad idea to deal with a model directly from an action instead of passing a associative-array like data to model.present() ?
For example:
function actionsLaunch()
{
model.start() //Set model->started member to true
model.present()
}
Instead of:
actions.launch = function(data, present) {
present = present || model.present ;
data.launched = true ;
present(data) ;
}
I'm trying to port it to PHP, and see how it look in an Object-Oriented like style.
Thanks you