Skip to content
This repository was archived by the owner on Jul 29, 2022. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions contributed/jquery.jeditable.checkbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**********************************************************************
* Custom input types for the jquery.jeditable plugin
* First version by Richard Davies <Richard__at__richarddavies.us>
*
* FIXES by Sardorbek Pulatov : BFM (http://bluefountainmedia.com)
*********************************************************************/

// Create a custom input type for checkboxes
$.editable.addInputType("checkbox", {
element : function(settings, original) {
var input = $('<input type="checkbox">');
$(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);
}
});