Multiple textarea on the same page, only first shows
When trying to use bootstrap-wysihtml5 on multiple textarea on the same page using the latest code in github, only the first one shows. After much debugging I discovered that...
Script from demo page works:
http://jhollingworth.github.com/bootstrap-wysihtml5/src/bootstrap-wysihtml5.js
Script direct from git src doesn't:
https://raw.github.com/jhollingworth/bootstrap-wysihtml5/master/src/bootstrap-wysihtml5.js
I created a jsFiddle to reproduce: WORKS - http://jsfiddle.net/enalmada/SBpyt/7/ FAILS - http://jsfiddle.net/enalmada/SBpyt/8/
Which code is newest, demo or src? If src, perhaps something that was put in broke it?
This is variant of your filldle that is working:
http://jsfiddle.net/wZjeW/1/
I think it should be very easy to make fixes to the script itself.
Ok, so to use the latest code for now we need to explicitly add ids and then run an each:
<textarea class="textarea" id="ta1" placeholder="Enter text ..." style="width: 810px; height: 200px"></textarea>
<textarea class="textarea" id="ta2" placeholder="Enter text ..." style="width: 810px; height: 200px"></textarea>
...
<script>
$(".textarea").each(function(){$(this).wysihtml5();});
</script>
Thanks for looking into this.
Actually, running "each" is enough. id's are just artefacts from debugging; you don't need them to run the script :)
:+1: — discovered this on my own, each() is required for multiple textareas.
<textarea class="wysihtml5 form-control"></textarea>
<script type="text/javascript">
$(document).ready(function () {
$('.wysihtml5').wysihtml5();
});
</script>
Just for completeness. This repo is not maintained anymore. In my fork https://github.com/Waxolunist/bootstrap3-wysihtml5-bower you will find a working example for multiple texteditors on one page.