0

I want to get categories ids from the select box which are selected in the product add/edit time on the admin side by Jquery.

I tried to get value from the hidden box but not able to find a hidden box for selected categories id in product form.

enter image description here

4
  • Add your code to the question as well which you have tried. Jan 6, 2021 at 17:31
  • Actually, I am trying to get a category id from this box by jquery but there is no ID. I did not write code yet. Jquery line $('#categories_id').val() but that field don't have any id Jan 7, 2021 at 3:58
  • Atleast first start with the code by checking the events and all Jan 7, 2021 at 3:59
  • Let me try first Jan 7, 2021 at 4:08

1 Answer 1

0

It's a UI component so we need to get it via uiRegistry and then get the value:

uiRegistry.get('product_form.product_form.product-details.container_category_ids.category_ids').value();

And put 'uiRegistry' as one of the dependencies of my js file. Below are the full code of my js file

require([
    'jquery',
    'uiRegistry'
], function ($,uiRegistry) {
    'use strict';
    jQuery(document).ready(function () {
       var category_ids=uiRegistry.get('product_form.product_form.product-details.container_category_ids.category_ids').value();

    });
});

Your Answer

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

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