PDA

View Full Version : How to get successful MSG with MVC?



feva
2 Nov 2011, 11:19 PM
//Controller//Store: Admin
this.getAdminStore().sync({
success: function(batch, option){
alert(option.operations.update[0].raw.id);
//How to get the response MSG at here?
}
// ,failure: function(batch, option){
// ...
// }
});

feva
3 Nov 2011, 12:27 AM
Think to oneself.
this.getReader().rawData.success

But I don't konw how to set response:
1.
{
success:true,
data:{
msg: '...'
}
}
2.
{
success:true,
msg: '...',
data:{

}
}

Which one is standard?

mitchellsimoens
3 Nov 2011, 7:07 AM
If you have structure like this:


{
success : true,
data : [...]
}

And your reader is setup like this:


{
type : 'json',
root : 'data'
}

Then I would say you should put things in the root level like:


{
success : true,
msg : 'Something here',
data : []
}

As the reader is expecting valid record objects in the data array. Here is how I do it:


var reader = store.proxy.reader,
msg = reader.createAccessor('msg')(reader.rawData);