diff --git a/contributed/jquery.jeditable.checkbox.js b/contributed/jquery.jeditable.checkbox.js new file mode 100644 index 0000000..faa33bf --- /dev/null +++ b/contributed/jquery.jeditable.checkbox.js @@ -0,0 +1,47 @@ +/********************************************************************** + * Custom input types for the jquery.jeditable plugin + * First version by Richard Davies + * + * FIXES by Sardorbek Pulatov : BFM (http://bluefountainmedia.com) + *********************************************************************/ + +// Create a custom input type for checkboxes +$.editable.addInputType("checkbox", { + element : function(settings, original) { + var input = $(''); + $(this).append(input); + + $(input).bind('click', function() { + if ($(input).val() == 'on') + { + $(input).val('off'); + $(input).removeAttr("checked"); + } + else{ + $(input).val('on'); + $(input).attr("checked", 'checked'); + + } + }); + + return(input); + }, + + content : function(string, settings, original) { + + var checked = (string == 'yes') ? 'on' : 'off'; + var input = $(':input:first', this); + + if (checked == 'on') + { + $(input).attr("checked", checked); + } + else + { + $(input).removeAttr("checked"); + } + + var value = $(input).attr("checked") ? 'on' : 'off'; + $(input).val(value); + } +});