0

Here i have a requirement to build SKU. Basing on category,subcategory & brand. Rule is to con-cat 1st 3 chars of categories and subcategories and brand followed by DB increment number. At the movement data entry guy is manually entering SKU. which i have to automate.

Below are the screen shots for understanding. enter image description here

enter image description here

enter image description here

Usualy in normal java script i would have simply call category element and concat it. But in knowckoutjs i am clue less.when i see inspect elements it has data-bind.

<input class="admin__control-text" type="text" data-bind="
        event: {change: userChanges},
        value: value,
        hasFocus: focused,
        valueUpdate: valueUpdate,
        attr: {
            name: inputName,
            placeholder: placeholder,
            'aria-describedby': noticeId,
            id: uid,
            disabled: disabled
    }" name="product[sku]" placeholder="" aria-describedby="notice-VCC6U0W" id="VCC6U0W">

i have tried pulling value using below code.i have placed below code in one of the common pages wizard.phtml.

function AppViewModel() {
       this.value = ko.observable("Enter String");
    }, this);
   }

   // Activates knockout.js
   ko.applyBindings(new AppViewModel());

any one help me in concatenating product categories.thanks in advance.

  • 1
    Well you can code simple jQuery there too. Like this require([ 'jquery' ], function ($) { $(document).ready(function() { alert('hii'); }); }); – Kingshuk Deb Apr 19 '17 at 12:57
  • but when i say $("xxxxx").val() it will give undefined, as there is no attribute value – 3bu1 Apr 19 '17 at 13:07
  • Where you are doing it? In console or in code? If in console then it should work as expected. But if you are coding it then you need to use jQuery as module in rquirejs. Copy the code i have given and try to delete the alert part and add your code over there. – Kingshuk Deb Apr 19 '17 at 13:12
  • require([ 'jquery' ], function ($) { $(document).ready(function() { alert($("input[type=text][name='product[sku]']").val()); }); }); this is my code...it says undefined. – 3bu1 Apr 19 '17 at 13:57

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.