I am using jEditable a jQuery plug-in and is is really cool for inline editing. I stuck when I had to add size(say 50 characters) field and css for an input field which is inline editable.
Then, I extended jeditable and added my own input type with size and class attributes:
In anything.js:
$(document).ready(function(){
jQuery.editable.addInputType('custom_input', {
element : function(settings, original) {
var input = $('<input size=50 class="input_inline"/>');
if (settings.width != 'none') { input.attr('width', settings.width); }
if (settings.height != 'none') { input.attr('height', settings.height); }
/* https://bugzilla.mozilla.org/show_bug.cgi?id=236791 */
//input[0].setAttribute('autocomplete','off');
input.attr('autocomplete','off');
$(this).append(input);
return(input);
}
});
});
$(".mouseover").editable('<custom url>', {
indicator : '<custom image path>',
onblur : "submit",
placeholder : "click here to edit",
type : "custom_input"
});
In any.html:
<div class="mouseover"></div>
so all div with mouseover class will become inline editable.
Then, I extended jeditable and added my own input type with size and class attributes:
In anything.js:
$(document).ready(function(){
jQuery.editable.addInputType('custom_input', {
element : function(settings, original) {
var input = $('<input size=50 class="input_inline"/>');
if (settings.width != 'none') { input.attr('width', settings.width); }
if (settings.height != 'none') { input.attr('height', settings.height); }
/* https://bugzilla.mozilla.org/show_bug.cgi?id=236791 */
//input[0].setAttribute('autocomplete','off');
input.attr('autocomplete','off');
$(this).append(input);
return(input);
}
});
});
$(".mouseover").editable('<custom url>', {
indicator : '<custom image path>',
onblur : "submit",
placeholder : "click here to edit",
type : "custom_input"
});
In any.html:
<div class="mouseover"></div>
so all div with mouseover class will become inline editable.
6 comments:
Hi,
I need to dynamically change width and height of the input. Is it possible in your solution?
I assume it's done by parameter settings, but I don't know how to use it.
Thanks
Hi,
I need to dynamically change width and height of the input. Is it possible in your solution?
I assume it's done by parameter settings, but I don't know how to use it.
Thanks
I think you can dynamically change the size of input element.
In my code:
...
...
element : function(settings, original, dynamicSize) {
var input = $('<input size=' + dynamicSize.toString +' class="input_inline"/>');
...
...
Let me know if this help.
Perfect solution for an issues that's bugged me for a while. Thanks.
Thanks for the code, very helpful
@LAN|)O, I am glad it helped you!
Post a Comment