Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
Knockout binding does not work with the disabled option
posted

It looks like this feature is not supported at all. Do you confirm this?

Here is the test to reproduce the bug: http://codepen.io/anon/pen/yjhgz

Clicking on the button should enable the text editor.

  • 3115
    Suggested Answer
    Offline posted

    Hi Francesc Baeta,

    The enable/disable binding is native for knockout and it's supported. But not inside the editor. It should be inside the same data-bind attribute, but outside the extension declaration. In example:

    data-bind="igTextEditor: { value: customerName}, disable: isDisabled ", where both customerName and isDisabled are observables.

     

    Here si jsFiddle example with a couple of editors with disable binding:

    http://jsfiddle.net/todorpaskalev/L3afN/5/

     

    Thanks,

  • 185
    Suggested Answer
    posted

    It looks like this feature is not yet implemented. Here's an implementation example to make igTextEditor support binding on the "disabled" option.

    (function() {
    	var igTextEditor = ko.bindingHandlers.igTextEditor;
    	ko.bindingHandlers.igTextEditor = {
    		init : function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
    			igTextEditor.init(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext);
    		},
    		update : function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
    			var disabled, current, editor = $(element);
    			igTextEditor.update(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext);
    			disabled = ko.utils.unwrapObservable(valueAccessor().disabled);
    			current = editor.igTextEditor("option", "disabled");
    			if (current !== disabled) {
    				editor.igTextEditor("option", "disabled", disabled);
    			}
    		}
    	};
    })();
    

    BTW, is the binding of all igEditor options planned in future releases?