I am in need to trigger some script with "text/x-magento-init" on ajax call but I am unable to do so.


contentUpdated is also not working in my case.

I am using contentUpdated as:


On console log(response.categoryProducts) I can see that x-magento-init script but the effect is not shown on frontend on using this way.

Any help ??

2 Answers 2


I found a solution for my question at last. I used 'applyBindings()' as 'contentUpdated' was not working in my case. Like

if ($.fn.applyBindings != undefined) {

Hope that this may help some one else as well. For more details have a look at this link: https://codeblog.experius.nl/magento-2-uicomponent-reinit-ajax-reload/

  • Thanks @Narendra for posting answer, +1 for your answer. Nov 1, 2018 at 9:25

Try like

    var contentBlock = this.element.find('.page-footer');
        url: this.options.contentsUrl,
        type: 'GET',
        dataType: 'html',
        data: {
            'form_key': FORM_KEY,
            node: node.id
        context: contentBlock,
        showLoader: true
    }).done(function (data) {


  • Tried but no luck :( not getting where I am wrong Nov 1, 2018 at 6:35
  • Did you get any response into response.categoryProducts?
    – Hitesh
    Nov 1, 2018 at 6:37
  • Yes I am getting whole Html in its response, and all html content is displaying correctly accept that x-magento-init block. And that script with x-magento-init is also I am getting in response, I have checked by console log whole data Nov 1, 2018 at 6:38
  • try this $('.page-footer').append(response.categoryProducts).trigger('contentUpdated'); In which file you ahve write this code?
    – Hitesh
    Nov 1, 2018 at 6:38
  • Actually we have used Amasty extension for shop by ajax, so I am writing this amasty extension js file i.e. amShopbyAjax.js Nov 1, 2018 at 6:41

Your Answer

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

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