Ad

Is There Call Back Function Of JavaScript In Infinite Options By ShopPad?

- 1 answer

I am developing a product detail page with the plugin called Infinite Options by ShopPad. I am trying to add HTML elements into the DOM generated by it, but it takes about 1 - 2 seconds after the page displays.

So I tried this way:

$(window).on('load', function () {
  function retry() {
    var $pluginHTML = $('.plugin ul');
    if (!$pluginHTML.length) return setTimeout(retry, 2000);
    $pluginHTML.css('fontColor','red');
  }
  retry();
});

It normally works well, but this is not the best solution.

Somebody knows if Infinite Options provides with callback function of JavaScript?

Ad

Answer

Infinite Options contains a callback function you can tie into that is defined at window.Shoppad.apps.infiniteoptions.ready.

For example:

  <script>
  window.Shoppad = window.Shoppad || {},
  window.Shoppad.apps = window.Shoppad.apps || {},
  window.Shoppad.apps.infiniteoptions = window.Shoppad.apps.infiniteoptions || {},
  window.Shoppad.apps.infiniteoptions.ready = function() {
    console.log('app loaded');
  };
  </script>
Ad
source: stackoverflow.com
Ad