I am using KO.JS and building a html template.
I want to display TinyMCE Preview by calling its preview command in the html binding.
In general, this is how we render the preview for tinymce on an external button click :
var preview = function (divName) {
var ID = divName
var myEditor = tinyMCE.editors["divName"];
myEditor.execCommand("mcePreview");
}
Note: I have multiple DIVs with the TinyMCE RTE, so passing divName as parameter.
My Problem Area:
I want to render the preview in a DIV using the above function. I am trying to call the same command in my Template Script.
Below is my template code :
<script type="text/html" id="tmplPreviewModal">
// Lots of other bindings go here //
// Below code should bind Tiny MCE RTE Preview to our DIV //
<div data-bind="html : {'tinymce.get('id': 'myTxtArea').execCommand('mcePreview'); '} "></div>
</script>
This code doesnt work, also throws error as shown in below screenshot :
Is it not possible to write my JS code within the template binding?
I even tried calling the JS Function preview
as shown below:
Please suggest