I
I
Ilyaploskov2019-12-25 13:01:39
JavaScript
Ilyaploskov, 2019-12-25 13:01:39

How to add multiple market.yandex widgets to one page?

Greetings. The documentation has an example:

<script async src="https://aflt.market.yandex.ru/widget/script/api" type="text/javascript"></script>
<script type="text/javascript">
  (function (w) {
    function start() {
      var widgetParams = [
        {
          containerId: "marketWidget1",
          ...   // Свойства первого виджета
        },
        {
          containerId: "marketWidget2",
          ...   // Свойства второго виджета
        },
        ...
      ];
      w.removeEventListener("YaMarketAffiliateLoad", start);
      for (var i = 0; i < widgetParams.length; i++) {
        w.YaMarketAffiliate.createWidget(widgetParams[i]);
    }
    w.YaMarketAffiliate
      ? start()
      : w.addEventListener("YaMarketAffiliateLoad", start);
  })(window);
</script>

<div id="marketWidget1"></div>
...
<div id="marketWidget2"></div>

I'm trying to do https://codepen.io/ilya-vins/pen/VwYWwQM and I can't figure out where the error is in the syntax. I ask the experts to help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
n1ksON, 2019-12-25
@n1ksON

In the last line, at its beginning, you need to put one more }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question