View Full Version : How not to set response data on model when performing Model.save()???

1 Aug 2012, 2:09 PM
I'm going to guess that this is much harder to do than it should be...

Using ExtJS 4.0.7, right now I have a Model w/ Rest proxy that I auto save upon any change to the models fields. When the response is returned from the server, it is set upon that model. These Models are loaded from a Store, but are intended to be saved individually.

The problem is I have a highly interactive UI in which that model may have already been modified prior to the save completing. Thus the response from the original save is now stale. Since the save sets it's stale data on the model, this can result in some glitchy behavior. Think updated positional data that suddenly gets set to an old position. Not cool.

What I am looking for is a way to tell a given Model.save "don't apply the response data to yourself...you already have everything necessary".

Thoughts? Any help is appreciated!!!!!

1 Aug 2012, 4:36 PM
Can you use getChanges to determine if the model is changed?


1 Aug 2012, 6:22 PM
Hi Scott,

I don't see how that would help me much. What I want is for the Model.save() to ignore the response data, not to avoid saving. Actually, I just re-found this old forum post that describes my problem/request very well: http://www.sencha.com/forum/showthread.php?152106-Model.save()-breaks-if-server-doesn-t-respond-with-updated-record-data

(http://www.sencha.com/forum/showthread.php?152106-Model.save()-breaks-if-server-doesn-t-respond-with-updated-record-data)I'll give that a try but this is something that *really* belongs in the framework. ExtJS is actually breaking with conventional REST in requiring that a model is returned on PUT's, and there may be many times that we have to interact with an API that does not even allow for a model in the response.

2 Aug 2012, 7:15 AM
So the fix proposed by charris doesn't work for me, as it still sets the model's data to that which the model had at the start of the Model.save(), it merely ignores the response, if there even is one. What I want is something that entirely avoids setting the models data at the completion of the Model.save().

Thoughts? Does this even make sense?