1

I want to remove html element from template file using knockout.js code. I have write my code in shipping.js which is getting called on checkout page. In shipping.js under i have defined my variable hideShippingHtml: ko.observable

     return Component.extend({
        hideShippingHtml: ko.observable(false),
       isVisible: ko.observable(quote.isVirtual()),
        quoteIsVirtual: quote.isVirtual()

           ......
     }),

on frontend in shipping.html template i called it for the div i want to remove

Method 1:

       <div if="hideShippingHtml">Jackson Villey</div>

Method 2:

                <div data-bind="visible: hideShippingHtml">Jackson Villey</div>

Method 3:

                <div data-bind="if: hideShippingHtml">Jackson Villey</div>

In console getting error that : ReferenceError: hideShippingHtml is not defined seems like data-binding error.

What could be the issue? Any help would be appreciated!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.