bootstrap-wysihtml5 icon indicating copy to clipboard operation
bootstrap-wysihtml5 copied to clipboard

Multiple textarea on the same page, only first shows

Open Enalmada opened this issue 12 years ago • 6 comments

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?

Enalmada avatar Dec 17 '12 04:12 Enalmada

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.

ysilvestrov avatar Dec 20 '12 20:12 ysilvestrov

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.

Enalmada avatar Dec 20 '12 20:12 Enalmada

Actually, running "each" is enough. id's are just artefacts from debugging; you don't need them to run the script :)

ysilvestrov avatar Dec 20 '12 21:12 ysilvestrov

:+1: — discovered this on my own, each() is required for multiple textareas.

statico avatar May 26 '13 18:05 statico

<textarea class="wysihtml5 form-control"></textarea>

<script type="text/javascript">
$(document).ready(function () {
$('.wysihtml5').wysihtml5();
});
</script>

nadiyapara avatar Jul 07 '14 07:07 nadiyapara

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.

Waxolunist avatar Jul 07 '14 09:07 Waxolunist