bgrins / ExpandingTextareas

jQuery plugin for elegant expanding textareas
http://bgrins.github.com/ExpandingTextareas/
MIT License
261 stars 73 forks source link

Using class names instead of id's to call this plugin. Possible? #17

Closed appel closed 12 years ago

appel commented 12 years ago

Thank you for your time and effort creating this plugin! There's a whole bunch of these autogrow plugins floating around the internet but your version takes home the cake!

One thing I haven't quite nailed yet is how to use a class name instead of an id to call this plugin, if even possible. The reason being that I'm using the plugin in a script that dynamically creates textareas, hence the id is unknown. Of course I could make it work (and in fact, made it work) by also creating the call on the fly, like so (shortened for brevity):

echo '<script>$(document).ready(function(){$("#'.$textareaid.'").expandingTextarea();});</script>';

But graceful, as I'm sure you'd agree, it is not. Thanks in advance!

bgrins commented 12 years ago

It is a standard jQuery plugin, so you should be able to just say $(".myclass").expandingTextarea();. Or, if you use the class of expanding, the plugin will automatically run: <textarea class='expanding'></textarea>. Does this make sense?

appel commented 12 years ago

Does this make sense?

It does! I'm not sure how it wasn't working before but it is now. Thank you!