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

Problem when updating viewModel with 'null' value for wysiwyg bound field. #17

Open matracey opened 9 years ago

matracey commented 9 years ago

I'm using knockout mapping to simplify my life when updating my model via ajax, although this issue applies with or without Knockout mapping. The problem arises when one of my WYSIWYG fields returns a null value and needs to be updated with this null value. The update function makes a tinymce.setContent( value ); call (wysiwyg.js:53), which will break when it gets to TinyMCE if value is null. I can work around this quite easily by updating the WYSIWYG field's value from null to an empty string.

Perhaps we could add a null check to this plugin when update is called and set value to an empty string if null? Or even a more friendly error message, as there isn't currently any kind of check in place!