Mika,
I tried adding this to the latest jeditable build from github @ line
237 where the plugin settings were included. This had the effect of
breaking jeditable as a whole.
I then tried it near the bottom where I have added in the new plugin
feature for checkboxes:
// Create a custom input type
for checkboxes
$.editable.addInputType("checkbox", {
element : function(settings, original) {
var input = $('<input
type="checkbox">');
$(this).append(input);
// Update <input>'s
value when clicked
$(input).click(function() {
var value =
$(input).attr("checked") ? 'Yes' : 'No';
$(input).val(value);
});
return(input);
},
content : function(string, settings,
original) {
var checked = string ==
"Yes" ? 1 : 0;
var input =
$(':input:first', this);
$(input).attr("checked", checked);
var value =
$(input).attr("checked") ? 'Yes' : 'No';
$(input).val(value);
}
});
By making this change:
$.editable.addInputType("checkbox", {
element : function(settings, original) {
var input = $('<input
type="checkbox">');
$(this).append(input);
// Update <input>'s
value when clicked
$(input).click(function() {
var value =
$(input).attr("checked") ? 'Yes' : 'No';
$(input).val(value);
});
return(input);
},
content : function(string, settings,
original) {
var checked = string ==
"Yes" ? 1 : 0;
var input =
$(':input:first', this);
$(input).attr("checked", checked);
var value =
$(input).attr("checked") ? 'Yes' : 'No';
$(input).val(value);
}
plugin : function(settings, original) {
$("input", this).attr("checked", true);
},
However I had no luck here as well. What I've got is great except for
the whole double click thing to edit a check box.
So figuring I have the chainability wrong I tried this adding in just
the snippet:
// Create a custom input type
for checkboxes
$.editable.addInputType("checkbox", {
element : function(settings, original) {
$("input", this).attr("checked",
true);
var input = $('<input
type="checkbox">');
$(this).append(input);
// Update <input>'s
value when clicked
$(input).click(function() {
var value =
$(input).attr("checked") ? 'Yes' : 'No';
$(input).val(value);
});
return(input);
},
content : function(string, settings,
original) {
var checked = string ==
"Yes" ? 1 : 0;
var input =
$(':input:first', this);
$(input).attr("checked", checked);
var value =
$(input).attr("checked") ? 'Yes' : 'No';
$(input).val(value);
}
});
And jeditable works but there is still the double click issue. Any
more ideas?
Brian
On Feb 12, 2009, at 12:27 AM, Mika Tuupola wrote:
On Feb 11, 2009, at 7:13 PM, Brian Loomis wrote:
Unfortunately I am not able to get the checkbox to select without
first selecting the containing element (which has the appearance of
having to get the checkbox a double click to check it) However -
the checkbox unselects with only one click. I do not have to click
the containing element to get this behavior.
I would like to get the checkbox to select with one click - before
my designer whomps me with the usability paddle and makes me do a
tear out and use standard forms.
Sorry but I do not understand your explanation what you are trying
to do.
Do you want the checkbox to be automatically checked when you click
editable element and the checkbox appears? You could try adding this
to you custom input code:
-cut-
plugin : function(settings, original) {
$("input", this).attr("checked", true);
},
-cut-
You need to set checked in plugin method instead of element because
browsers are a bit touchy when value of input is set.
--
Mika Tuupola
http://www.appelsiini.net/