My desired scenario is that the value entered into a bound input
field shouldn't propagate to the model until save button is clicked. I found this topic: Emberjs: Prevent changes propagation throughout a transaction however it's quite old. Is there another way to accomplish this?
Asked
Active
Viewed 103 times
0
1 Answers
0
You might want to try ember-buffered-proxy.
var buffer = BufferedProxy.create({
content: modelInstance
});
buffer.set('name', 'something');
// apply the changes to the model
buffer.applyBufferedChanges();
modelInstance.save();
// or discard the changes
buffer.discardBufferedChanges();
If you bind the input to the property on buffer
instead of modelInstance
and call buffer.applyBufferedChanges();
ok save it will give you the behaviour you want.

jmurphyau
- 2,309
- 13
- 11
-
I started writing something similar myself but I was hoping that there's some built-in functionality that would work that way. Still, I'm gonna accept this answer. – Marek M. Jun 26 '15 at 11:03
-
What's the problem with using the mode directly? Calling `.save()` when save is pressed and `rollback()` (or the new version which I think is `rollbackAttributes()`) to revert the value back to its original state? – jmurphyau Jun 26 '15 at 11:17
-
Interesting @jmurphyau. OP, are you using Ember Data? What is the reason why you need this different behaviour? Just curious. – Christopher Milne Jun 26 '15 at 11:38