angular-toggle-switch icon indicating copy to clipboard operation
angular-toggle-switch copied to clipboard

Add beforeToggle callback ?

Open xhuberdeau opened this issue 10 years ago • 0 comments

Hi, Would it be possible to add a callback before the switch is toggled ? Currently, I load data via Ajax from a DB. There is an boolean attribute for each line of this data, which is the model for each toggle switch. My use case is : When you click on the toggle, it updates the attribute in DB. My problem is that the toggle is switched before the ajax request is done. In case of a servor error, the toggle is switched let's say to "yes", the ajax return an error, the toggle is switched back to "no".

I'd like to wait for the ajax response before any switch happens. How would you do that ? Watching my data is not useful there.

Thanks.

xhuberdeau avatar Sep 03 '15 10:09 xhuberdeau