Skip to content
Snippets Groups Projects
Commit b265023d authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Support for multiple tinyMCE instances with different config options.

parent caa6e309
Branches
Tags
No related merge requests found
......@@ -31,9 +31,29 @@ QfqNS.Helper = QfqNS.Helper || {};
return;
}
tinymce.init({
selector: ".qfq-tinymce",
setup: function (editor) {
$(".qfq-tinymce").each(
function () {
var config = {};
var $this = $(this);
var tinyMCEId = $this.attr('id');
if (!tinyMCEId) {
QfqNS.Log.warning("TinyMCE container does not have an id attribute. Ignoring.");
return;
}
var configData = $this.data('config');
if (configData) {
try {
config = JSON.parse(configData);
} catch (e) {
QfqNS.Log("Exception while parsing JSON: " + configData);
QfqNS.Log(e);
return;
}
}
config.selector = "#" + tinyMCEId;
config.setup = function (editor) {
editor.on('Change', function (e) {
console.log('Editor was changed');
var eventTarget = e.target;
......@@ -41,8 +61,11 @@ QfqNS.Helper = QfqNS.Helper || {};
$parentForm.trigger("change");
});
};
tinymce.init(config);
}
});
);
};
tinyMce.prepareSave = function () {
......
......@@ -67,6 +67,18 @@
</div>
<div class="form-group">
<div class="col-md-2">
<label for="text2" class="control-label">Rich Text Editor</label>
</div>
<div class="col-md-6">
<textarea id="text2" class="qfq-tinymce" name="rte">Input
</textarea>
</div>
</div>
<button type="submit">Do</button>
</form>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment