Reputation: 2025
Using Jquery plugin Jeditable to create a form. I have been hacking around trying to combine the charcount plugin and the autogrow from the custom demo page here: http://www.appelsiini.net/projects/jeditable/custom.html. I'm not clever enough with jquery plugins to figure it out. I am not sure if I can simply have multiple plugins or do I actually need to figure out a way to merge the code? Any pointers?
Upvotes: 0
Views: 767
Reputation: 22862
If you look at the source code for both jedtable-charcounter (http://www.appelsiini.net/projects/jeditable/jquery.jeditable.charcounter.js) and jeditable-autogrow (http://www.appelsiini.net/projects/jeditable/jquery.jeditable.autogrow.js), you can see that they're basically the same.
I think you can combine like this:
$.editable.addInputType('hybrid', {
element : function(settings, original) {
var textarea = $('<textarea />');
if (settings.rows) {
textarea.attr('rows', settings.rows);
} else {
textarea.height(settings.height);
}
if (settings.cols) {
textarea.attr('cols', settings.cols);
} else {
textarea.width(settings.width);
}
$(this).append(textarea);
return(textarea);
},
plugin : function(settings, original) {
$('textarea', this).charCounter(settings.charcounter.characters, settings.charcounter);
$('textarea', this).autogrow(settings.autogrow);
}
});
Make sure you reference both plugins.
Then you can call the jQuery like this:
$(document).ready(function() {
$(".hybrid").editable("http://www.appelsiini.net/projects/jeditable/php/save.php", {
type : "hybrid",
submit : 'OK',
tooltip : "Click to edit...",
onblur : "ignore",
charcounter : {
characters : 60
},
autogrow : {
lineHeight : 16,
minHeight : 32
}
});
Upvotes: 2