2

I have a code of jQuery:

    <script type="text/x-magento-init">
        {
            "*": {
                "magepowSizeGuide":{}
            }
        }
    </script>

What can be the meaning of * ?

Is this mean that this jQuery will work on all HTML element ?

1
  • I try console.log(this) in this function but it seem like no element select. Jul 26, 2019 at 10:17

2 Answers 2

1

I give you understanding through following example:

<script type="text/x-magento-init">
    {
        "*": {
            "Pulsestorm_JavascriptInitTutorial/example":{"config":"value"}
        }
    }        
</script>

The * we used previously is actually a special case, for programs that don’t need to operate on DOM nodes. The key for this object is actually a CSS/jQuery style selector that tells Magento which DOM nodes the program in Pulsestorm_JavascriptInitTutorial/example should operate on.

One of very good reference article: https://alanstorm.com/magento_2_javascript_init_scripts/

I hope this will help

3
  • Now, I understand. Thank you! Jul 26, 2019 at 10:50
  • 1
    Glad it helped you. keep coding :) thanks :) +1 on your question for appreciation Jul 26, 2019 at 10:51
  • Thank you for your help! Jul 26, 2019 at 10:54
1

"*" Is used to determine that you are using a new module in require js; if you want to add a file to the existing module, you will need to specify the name of the module instead of *.

4
  • I think it just like element, not module Jul 26, 2019 at 10:28
  • 1
    used to determine that you are using a new module in require js. existing module need to specify the name of the module Jul 26, 2019 at 10:40
  • Now, I understand. Thank you! Jul 26, 2019 at 10:53
  • 1
    @DavidDuong My pleasure! Jul 26, 2019 at 10:56

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.