vitalets / angular-xeditable

Edit in place for AngularJS
http://vitalets.github.io/angular-xeditable
MIT License
1.91k stars 403 forks source link

Debouncing? #670

Closed hk0i closed 7 years ago

hk0i commented 7 years ago

Is it possible to add debouncing via ng-model-options? I'm trying to store the editable changes in localStorage so if the user refreshes the page while editing, their unsaved changes are restored to them in the same editing state as when the refresh began.

I have something that resembles this simplified example now:

<li
    editable-text="myStorageModel"
    ng-model-options="{ debounce: 500 }">
    {{ myDisplayModel }}
</li>

I've tried with both ng-model-options and e-ng-model-options and neither one seems to trigger the debounce.

hk0i commented 7 years ago

Never mind I got this working by adding an e-ng-change:

<li
    editable-text="myStorageModel"
    e-ng-change="myStorageModel = $data"
    e-ng-model-options="{ debounce: 500 }">
    {{ myDisplayModel }}
</li>

I'm not sure if this is the best way, but we might want to consider adding even a localStorage feature with this type of capability built in.