michaelpapworth / tinymce-knockout-binding

A KnockoutJS custom binding that applies a TinyMCE Editor to the bound HTML element
MIT License
39 stars 19 forks source link

Issue with Knockout Validation #19

Open matracey opened 9 years ago

matracey commented 9 years ago

Seems to be an issue with the plugin and Knockout Validation (https://github.com/Knockout-Contrib/Knockout-Validation). The validation is reporting my observable as modified after TinyMCE has loaded, which in-turn is displaying my validation error prematurely.

Is there any way I can stop my observable's isModified value from being changed when TinyMCE loads?

jurion commented 9 years ago

You can load your model after TinyMCE is loaded. I use this :

    ko.bindingHandlers['wysiwyg'].defaults = {
        'setup': function( editor ) {
            editor.on( 'init', function( e ) {
                if (e.target.id == 'projectDescription') {
                   //load your model
                }
            });
        }
    };

Note : You probably don't need targetid check (I have multiple TinyMCE on the page, so I need to load model after the first one)