I have a checkbox that has some style on it so it looks like it's flipping. When the user presses the button it flips visually on the client side but I send a request off to the server to save that change to a database. If some error happens I'd like to reflip it on the client side. I'll know if something happens because the error callback of the http.post() will be raised. The question I have is how would I flip that checkbox back to it's original state?
Here is the visual I'm using for the checkbox. I'm using the flipable one: https://codepen.io/anon/pen/yXNopJ?editors=1100
Here is an example of the checkbox (one for each month)
<input class="tgl tgl-flip" id="cbJan_{{ s.MFGName }}" type="checkbox" ng-model="s.Jan" ng-change="vm.monthValueChanged(s.MFGName, 'Jan', s.Jan)" />
<label class="tgl-btn" data-tg-off="OFF" data-tg-on="ON" for="cbJan_{{ s.MFGName }}" ></label>
In my javascript code I tried to use jquery to build the id and check it but that didn't do anything. It didn't error and it didn't revert the checkbox.
function (error, status) {
alertify.delay(0).maxLogItems(3).closeLogOnClick(true).error('Error: ' + error.data.Message + ' <a href="#" class="close-icon"></a>');
var data = JSON.parse(error.config.data);
var name = 'cb' + data.Month + '_' + data.MFG;
console.log(name);
$(name).prop('checked', !data.Value);
// todo: negate data.Value to get the original value and set the checkbox to that state programmatically
}