Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Multiple instances #52

Closed
chrisharrison opened this issue Apr 20, 2013 · 12 comments
Closed

Multiple instances #52

chrisharrison opened this issue Apr 20, 2013 · 12 comments

Comments

@chrisharrison
Copy link

If you have a bunch of divs on the page with the same class ( .rte for instance), and apply the .wysiwyg method to them, they work perfectly with the hotkeys but the buttons don't work.

If however, you apply a div to each one ( #rte1 #rte2 etc) it does work. This is OK, and for me I can easily do that programmatically in the flow of my application. But it's not standard and caused a little bit of confusion for me, and perhaps a lot of hair pulling for others.

@elias-selinder
Copy link

Hi
I have the exact same problem with multiple instances. How did you apply a div to make it work? Do you have an example?
Thanks!

@gojko
Copy link
Contributor

gojko commented Apr 24, 2013

you can pass an option for the toolbar selector. By default, wysiwyg widget will use the data-role selector, but you can override it to bind to any JQuery selector (even IDs). So to prevent multiple instances to bind to all the toolbars, give toolbars IDs and pass different selectors into different instances. See line 192 of https://github.com/mindmup/bootstrap-wysiwyg/blob/master/bootstrap-wysiwyg.js

@gojko gojko closed this as completed Apr 24, 2013
@wenjie711
Copy link

Hi
I still don't know how to make it work with multiple instances.Could you give me an example?

@makusu
Copy link

makusu commented May 17, 2013

Hi @chrisharrison, @nossai, and @wenjie711,

If you still haven't figured out how to do this, this is something that you might want to do:

    $('#editor').wysiwyg();

    $('#editor2').wysiwyg({ toolbarSelector: '[data-role=editor2-toolbar]'} );

and change your btn toolbar into:

    <div class="btn-toolbar" data-role="editor-toolbar" data-target="#editor">

    <div class="btn-toolbar" data-role="editor2-toolbar" data-target="#editor2">

@beshur
Copy link

beshur commented Sep 7, 2013

Thank you for the explanation, guys.
But what if I want to use the same toolbar for different editor areas?
tnx

Is there a method to dynamically change options of the wysiwyg?

@sureshvtt
Copy link

Thanks for the example.

@JustWe
Copy link

JustWe commented Apr 10, 2014

Thanks!

@toledoroy
Copy link

Thanks @makusu !!

@ranjithnori
Copy link

Thanks @gojko and @makusu !

@klausrz
Copy link

klausrz commented Aug 14, 2014

thanks guy!

@neumachen
Copy link

@makusu how would you do that if you were cloning elements and want to have WYSIWYG enabled on each clone node?

@makusu
Copy link

makusu commented Aug 15, 2016

@magicalbanana Sorry for late reply. Busy these days.

You basically need to have 2 different IDs for each of the WYSIWYG element.

Please take it with a pinch of salt since my comment was well over 3 years ago.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests