Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read Only binding #30

Open
bindrid opened this issue Jun 27, 2017 · 0 comments
Open

Read Only binding #30

bindrid opened this issue Jun 27, 2017 · 0 comments

Comments

@bindrid
Copy link

bindrid commented Jun 27, 2017

I wanted to be able to tie the readonly status from the view model of the editor window. I finally settled on doing:

Before these lines

     // Get custom configuration object from the 'wysiwygConfig' binding, more settings here... http://www.tinymce.com/wiki.php/Configuration
var options = allBindings.has( 'wysiwygConfig' ) ? allBindings.get( 'wysiwygConfig' ) : null,
    // Get any extensions that have been enabled for this instance.
ext = allBindings.has( 'wysiwygExtensions' ) ? allBindings.get( 'wysiwygExtensions' ) : [],
     settings = configure( binding['defaults'], ext, options, arguments ); 

I added this:

		 binding['defaults'].setup =  function (editor) {
		    editor.on('init', function (e) {
		        if (allBindings.has('tinyMCEReadOnly')) {
                    // Set read only mode on init.
		            editor.setMode(allBindings.get('tinyMCEReadOnly')() ? 'readonly' : '');

                    // now subscribe to watch for more changes
		            allBindings.get('tinyMCEReadOnly').subscribe(function (isReadOnly) {
		                if (isReadOnly === true) {
		                    editor.setMode('readonly');
		                }
		                else {
		                    editor.setMode('');
		                }
		            });
		        }
		    });
		 }

and now my markup:

 <textarea id="divNoticeBody" readonly  data-bind="tinyMCEBinder: NoticeBody, tinyMCEReadOnly: NoticeReadOnly"></textarea>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant