Sha256: e7e39533f587486defd16cbeecc933581b636f70195ab1f1aa8e7c0cf8bc4d7a
Contents?: true
Size: 946 Bytes
Versions: 2
Compression:
Stored size: 946 Bytes
Contents
$(function() { $('.toggle-bool-switch').click(function(e) { var boolSwitch = $(e.target); var objectId = boolSwitch.data('object_id'); var model = boolSwitch.data('model'); var field = boolSwitch.data('field'); var url = boolSwitch.data('url'); var value = boolSwitch.data('value'); var successMessage = boolSwitch.data('success_message'); var data = { id: objectId }; data[model] = {}; data[model][field] = !value; $.ajax({ url: url, data: data, dataType: 'json', error: function() { var errorMsg = 'Error: Update Unsuccessful'; alert(errorMsg); }, success: function() { boolSwitch.data('value', !value); boolSwitch.toggleClass('on'); if (!boolSwitch.hasClass('notify-success')) return; $(function() { setTimeout(alert(successMessage), 500); }); }, type: 'PATCH', }); }); });
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activeadmin_addons-1.6.0 | app/assets/javascripts/activeadmin_addons/addons/toggle_bool.js |
activeadmin_addons-1.5.0 | app/assets/javascripts/activeadmin_addons/addons/toggle_bool.js |