I am getting following erro

knockout.js:3277 Uncaught Error: You cannot apply bindings multiple times to the same element.

Below is the code

var instance = new viewModel(initialData);
                        if(typeof(document.getElementById("menueditor")) !='underfined' && document.getElementById("menueditor")[0]){
                        var koNode = document.getElementById('menueditor');
                        var hasDataBinding = !!ko.dataFor(koNode);
                        console.log('has data binding', hasDataBinding);
                        if (!hasDataBinding) { ko.applyBindings(instance, koNode);}

1 Answer 1


This is because you are trying to apply the bindings which Magento already does, within Magento 2 you should never do this.

You will need to research UI Components to see how to use Knockout within Magento 2.

A very basic component utilising Knockout looks something like this:

], function (ko) {
    'use strict';

    return function (Component) {
        return Component.extend({
            exampleText: ko.observable('Hello')


 <div data-bind="text: exampleText"></div>

I've answered this in more detail on this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.