# Variantenwechsel über ajax

**URL:** <https://forum.shopware.com/t/variantenwechsel-uber-ajax/53860>\
**Category:** Programmierung\
**Created:** [4. Juli 2018 um 00:03 UTC](https://forum.shopware.com/t/variantenwechsel-uber-ajax/53860 "2018-07-04T00:03:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![omeganos](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@omeganos](https://forum.shopware.com/u/omeganos)\
**Post date:** [4. Juli 2018 um 00:03 UTC](https://forum.shopware.com/t/variantenwechsel-uber-ajax/53860/1 "2018-07-04T00:03:30Z")

</div>

Hallo zusammen,

ich verusche ein custom Scrollbar, genauer “mCustomScrollbar” von [malihu](http://manos.malihu.gr/jquery-custom-content-scroller/)&nbsp;in meinem shop einzubinden.

Soweit funktioniert alles ganz gut und die Initialisierung findet wie folgt statt:

```
(function($){
  $(window).load(function(){
        $(".configurator--form, .tab--container.has--content").mCustomScrollbar();
    });
})(jQuery);

```

frontend\index\header.tpl

Nun, bei Variantenwechsel über ajax greift das nicht mehr…&nbsp;

Ich habe alle ajax Calls mit Stop, Complete etc. schon versucht, ebenfalls für HTML und auch die Methoden die&nbsp;[malihu](http://manos.malihu.gr/jquery-custom-content-scroller/)&nbsp;zur Verfügung stellt… leider ohne Erfolg.

Kann mir bitte jemand (an etwas verständliche Code) erklären wie man das in Shopware 5 mit ajax realisiert?

PS: über .subscribe habe ich das auch eingebunden, dort spuckt die Console immer&nbsp;(…).mCustomScrollbar is not a function raus, egal wie ich es drehe…

Vielen Dank

---

<div class="post-metadata">

**Author:** ![gwen](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@gwen](https://forum.shopware.com/u/gwen)\
**Post date:** [11. März 2019 um 14:06 UTC](https://forum.shopware.com/t/variantenwechsel-uber-ajax/53860/2 "2019-03-11T14:06:12Z")

</div>

Hallo omeganos,  
&nbsp;

ich habe das Aufrufen der jQuery Funktionen beim Variantenwechsel so gelöst.

&nbsp;

```
  $.subscribe('plugin/swAjaxVariant/onRequestData', function() {
    //call function();
  });

```

Am besten legst du dir zwei js Dateien an. Eine, wo die Funktion selbst liegt und Eine mit dem Code oben&nbsp;swAjaxVariant\_mCustomScrollbar.js oder so. Und deinen Funktionsaufruf darin.

LG  
gwen
