From 26f89d50c0e3798a0c23dce2c5c431715c37cd68 Mon Sep 17 00:00:00 2001 From: Mauro Asprea Date: Thu, 19 Sep 2013 13:33:03 +0200 Subject: [PATCH] Fix to support multiple instances adding a wrapper context for toolbar's bindings --- bootstrap-wysiwyg.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bootstrap-wysiwyg.js b/bootstrap-wysiwyg.js index 69f64a7..58d95c9 100644 --- a/bootstrap-wysiwyg.js +++ b/bootstrap-wysiwyg.js @@ -20,12 +20,13 @@ }; $.fn.wysiwyg = function (userOptions) { var editor = this, + wrapper = $(editor).parent(), selectedRange, options, toolbarBtnSelector, updateToolbar = function () { if (options.activeToolbarClass) { - $(options.toolbarSelector).find(toolbarBtnSelector).each(function () { + $(options.toolbarSelector, wrapper).find(toolbarBtnSelector).each(function () { var command = $(this).data(options.commandRole); if (document.queryCommandState(command)) { $(this).addClass(options.activeToolbarClass); @@ -103,7 +104,7 @@ input.data(options.selectionMarker, color); }, bindToolbar = function (toolbar, options) { - toolbar.find(toolbarBtnSelector).click(function () { + toolbar.find(toolbarBtnSelector, wrapper).click(function () { restoreSelection(); editor.focus(); execCommand($(this).data(options.commandRole));