A good start
I asked this question "Codemirror - Use on multiple textareas?" a few years ago with a good answer. However, it still takes an ID as parameter. IDs are unique.
Find textarea by class instead of ID
When having multiple textareas, some with HTML and some with CSS on the same page, it would be nice to add a class instead of an ID.
Example
<p>Some content</p>
<textarea class="my_codemirror_html">
</textarea>
<p>Some content</p>
<textarea class="my_codemirror_html">
</textarea>'
If I can use jQuery for it, it's fine. I use that anyway on the page.
Update 2012-02-21 - Almost there
I found this post on jsFiddle. The only thing missing is that I can't make it work on textareas.
This will be an easier solution with less complexity.
$('.my_codemirror_html').each(function(index, elem){
CodeMirror.fromTextArea(elem, {/*options*/});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With