0

I would like to get the value of the SKU input in the admin product form. I am currently getting the value using jQuery but would like to start leveraging KnockoutJS.

Simply put, instead of using the code below I would like to leverage KO. I have searched around and could not find something suitable to my needs in terms of tutorials so I am asking here.

require([
        'uiComponent',
        'ko',
        'jquery',
        'domReady!',

    ], function (Component, ko, $,domReady) {
        "use strict";
    $(document).on('ajaxComplete', function (event, xhr, settings) {

          var productSKU = $('input[name="product[sku]"]');

          productSKU.on('keyup',function () {
              var data = {sku: this.value, new_product: 1};

              // ajax call using data 


          });
    }); 
});

I have a module built that uses a layout XML file to add a phtml file that has the following code to add my js file.

<script type="text/x-magento-init">
        {

            ".catalog-product-new": {
                "CustomSearch":{"config":"value"}
            }
        }
    </script>

I have attempted a with the limited KnockoutJs that I know but could not get it to work.

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.