Skip to content

Instantly share code, notes, and snippets.

@SoftwareMaven
Created November 20, 2012 01:40
Show Gist options
  • Save SoftwareMaven/4115396 to your computer and use it in GitHub Desktop.
Save SoftwareMaven/4115396 to your computer and use it in GitHub Desktop.
jEditable autocounter plugin (combination of autogrow and charcounter plugins)
/*
* A combination of jquery.editable's charcounter and autogrow plugins.
*/
$.editable.addInputType('autocounter', {
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);
}
textarea.addClass('charCounter');
textarea.addClass('autogrow');
$(this).append(textarea);
return(textarea);
},
plugin : function(settings, original) {
var char_settings = settings.autocounter.charcounter;
var grow_settings = settings.autocounter.autogrow;
$('textarea', this).autogrow(grow_settings).charCounter(char_settings.characters, char_settings);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment