Ryan Caskey
Ryan Caskey

Reputation: 607

tinymce-knockout-binding not showing formatting

I'm trying to get the tinymce-knockout-binding plugin by michaelpapworth (an awesome plugin by the way). The problem that I'm having is that I'm trying to bind an editor with some pre-existing html markup, but it's showing the tags instead of showing it formatted.

Here's a jsfiddle showing my problem: http://jsfiddle.net/rsparkyc/MT7cf/2/

My view model is as follows:

function ViewModel() {
    var self = this;
    self.wysiwygOptions = {
        forced_root_block: false
    };


    self.selectedText = 
      ko.observable('I want this<br /><h1>to show formatting</h1>In the editor');
}

and I'm binding to the observable like this:

<div class="editableArea" 
     data-bind="wysiwyg: selectedText, wysiwygConfig: wysiwygOptions"></div>

Upvotes: 2

Views: 248

Answers (2)

G&#244;T&#244;
G&#244;T&#244;

Reputation: 8053

You initialize your binding with a text instead of a html:

e(i).html(s()());

Corrected jsFiddle

Upvotes: 0

Gabriel Doty
Gabriel Doty

Reputation: 1786

On Line 14 of the plugin

e(i).text(s()());

This assumes you are posting plain text... You can change this line to

e(i).html(s()());

and it will correctly format.. I believe that the setContent function used on the update already accommodates HTML so should not need further upgrades

Upvotes: 1

Related Questions