Sha256: f90fcae47020957a17a2761c1e63cd3f31d3d48952a1fb80892722ebbf1eabaf
Contents?: true
Size: 1.06 KB
Versions: 11
Compression:
Stored size: 1.06 KB
Contents
jQuery(document).ready(function($) { new activableOption(); }); var activableOption = function(){ var _this = this; this.$links = $('.activable'); this.startup = function(){ if(!this.$links[0]){ return false; } this.$links.on('change', function(event) { event.preventDefault(); if($(this).is(':checked')){ _this.active($(this)); }else{ _this.inactive($(this)); } }); }, this.active = function($link){ $.ajax({ url: '/loldesign_publisher/activables/'+$link.data('resource')+'/'+$link.data('id')+'.json', type: 'POST', dataType: 'json' }) .done(function() { $link.val(true); }) .fail(function() { console.log("error"); }); }, this.inactive = function($link){ $.ajax({ url: '/loldesign_publisher/activables/'+$link.data('resource')+'/'+$link.data('id')+'.json', type: 'DELETE', dataType: 'json' }) .done(function() { $link.val(false); }) .fail(function() { console.log("error"); }); }, this.startup(); }
Version data entries
11 entries across 11 versions & 1 rubygems