# Tipps für folgenden Fehler: Uncaught TypeError: $.overridePlugin is not a function

**URL:** <https://forum.shopware.com/t/tipps-fur-folgenden-fehler-uncaught-typeerror-overrideplugin-is-not-a-function/54041>\
**Category:** Programmierung\
**Created:** [12. Juli 2018 um 10:18 UTC](https://forum.shopware.com/t/tipps-fur-folgenden-fehler-uncaught-typeerror-overrideplugin-is-not-a-function/54041 "2018-07-12T10:18:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![einfachich](https://avatars.discourse-cdn.com/v4/letter/e/ac8455/32.png) [@einfachich](https://forum.shopware.com/u/einfachich)\
**Post date:** [12. Juli 2018 um 10:18 UTC](https://forum.shopware.com/t/tipps-fur-folgenden-fehler-uncaught-typeerror-overrideplugin-is-not-a-function/54041/1 "2018-07-12T10:18:13Z")

</div>

Hallo Zusammen,

Sorry für den neuen Thread. Aber leider bekommt man in anderen absolut keine Antwort mehr. Daher neu. Entschuldigt. Aber an was könnte es liegen wenn ich andauernd die Fehler Meldung bekomme:

```
Uncaught TypeError: $.overridePlugin is not a function

```

Meine Quelldatei -\> unter meine custom template/theme im src Ordner:

```
$(function () {
    $.overridePlugin('swSearch', {
		/**
         * Triggers an AJAX request with the given search term.
         *
         * @public
         * @method triggerSearchRequest
         * @param {String} searchTerm
         */
        triggerSearchRequest: function (searchTerm) {
						
            var countDigitsMatch = searchTerm.match(/[0-9\\/]/g);
            var countDigits = countDigitsMatch == null ? 0 : countDigitsMatch.length;
            var countSpacesMatch = searchTerm.match(/ /g);
            var countSpaces = countSpacesMatch == null ? 0 : countSpacesMatch.length;
            var countTotal = searchTerm.length;
            var hasMoreDigitsThanChars = countDigits >= (countTotal - countSpaces - countDigits);
            
            if (searchTerm.match(/^[0-9\\/]*$/) !== null || hasMoreDigitsThanChars)
            {
                searchTerm = searchTerm.replace(/ /g, '').replace(/\//g, '_');
				console.log(searchTerm);
            }
            
            var me = this;

            me.$loader.fadeIn(me.opts.animationSpeed);

            me.lastSearchTerm = $.trim(searchTerm);

            $.publish('plugin/search/onSearchRequest', [me, searchTerm]);

            $.ajax({
                'url': me.requestURL,
                'data': {
                    'sSearch': me.lastSearchTerm
                },
                'success': function (response) {
                    me.showResult(response);
                    $.publish('plugin/search/onSearchResponse', [me, searchTerm, response]);
                }
            });
        }
    });
	
});

```

Für Eure Hilfe bin ich sehr dankbar.

&nbsp;

LG Tobias

---

<div class="post-metadata">

**Author:** ![wontfix](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@wontfix](https://forum.shopware.com/u/wontfix)\
**Post date:** [12. Juli 2018 um 10:49 UTC](https://forum.shopware.com/t/tipps-fur-folgenden-fehler-uncaught-typeerror-overrideplugin-is-not-a-function/54041/2 "2018-07-12T10:49:26Z")

</div>

und du&nbsp;hast die js datei pfad in die `$javascript` array in deine Theme.php addiert?  
[Using CSS and JavaScript in themes](https://developers.shopware.com/designers-guide/css-and-js-files-usage/#add-javascript-files)

wenn ja, vielleicht ohne die unnötige closure funktion probieren.

---

<div class="post-metadata">

**Author:** ![einfachich](https://avatars.discourse-cdn.com/v4/letter/e/ac8455/32.png) [@einfachich](https://forum.shopware.com/u/einfachich)\
**Post date:** [12. Juli 2018 um 11:07 UTC](https://forum.shopware.com/t/tipps-fur-folgenden-fehler-uncaught-typeerror-overrideplugin-is-not-a-function/54041/3 "2018-07-12T11:07:48Z")

</div>

Hi wontfix,

ja das habe ich gemacht. Danach kommt eben im Frontent diese Fehler Meldung “Uncaught TypeError: $.overridePlugin is not a function”

Habe auch nochmal nachgeschaut, das ich nicht irgendwo extra Jquery nochmal einbinde.

Auch so bekomme ich weiterhin diesen Fehler.

```
$.overridePlugin('swSearch', {
		/**
         * Triggers an AJAX request with the given search term.
         *
         * @public
         * @method triggerSearchRequest
         * @param {String} searchTerm
         */
        triggerSearchRequest: function (searchTerm) {
						
            var countDigitsMatch = searchTerm.match(/[0-9\\/]/g);
            var countDigits = countDigitsMatch == null ? 0 : countDigitsMatch.length;
            var countSpacesMatch = searchTerm.match(/ /g);
            var countSpaces = countSpacesMatch == null ? 0 : countSpacesMatch.length;
            var countTotal = searchTerm.length;
            var hasMoreDigitsThanChars = countDigits >= (countTotal - countSpaces - countDigits);
            
            if (searchTerm.match(/^[0-9\\/]*$/) !== null || hasMoreDigitsThanChars)
            {
                searchTerm = searchTerm.replace(/ /g, '').replace(/\//g, '_');
				console.log(searchTerm);
            }
            
            var me = this;

            me.$loader.fadeIn(me.opts.animationSpeed);

            me.lastSearchTerm = $.trim(searchTerm);

            $.publish('plugin/search/onSearchRequest', [me, searchTerm]);

            $.ajax({
                'url': me.requestURL,
                'data': {
                    'sSearch': me.lastSearchTerm
                },
                'success': function (response) {
                    me.showResult(response);
                    $.publish('plugin/search/onSearchResponse', [me, searchTerm, response]);
                }
            });
        }
});

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![wontfix](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@wontfix](https://forum.shopware.com/u/wontfix)\
**Post date:** [12. Juli 2018 um 11:51 UTC](https://forum.shopware.com/t/tipps-fur-folgenden-fehler-uncaught-typeerror-overrideplugin-is-not-a-function/54041/4 "2018-07-12T11:51:29Z")

</div>

hab eben in vanilla shopware 5.4.5 mit folgende theme probiert:

```
namespace Shopware\Themes\Foo;

use Doctrine\Common\Collections\ArrayCollection;
use Shopware\Components\Form as Form;
use Shopware\Components\Theme\ConfigSet;

class Theme extends \Shopware\Components\Theme
{
	protected $extend = 'Responsive';
	protected $name = 'Foo';
	protected $description = 'test theme';
	protected $author = 'bar';
	protected $license = 'MIT';
	protected $javascript = [
		'src/js/example.js'
	];
}

```

und deine javascript datei in `frontend/_public/src/js/example.js` addiert und es funktioniert.

was mir aufegaffallen ist:

- theme muss ‚Responsive‘ erweitern (weil nur diese hat die jquery plugins)
- der pfad in `$javascript` ist implizit relativ zu `frontend/_public/` (grauenhaft!)

---

<div class="post-metadata">

**Author:** ![einfachich](https://avatars.discourse-cdn.com/v4/letter/e/ac8455/32.png) [@einfachich](https://forum.shopware.com/u/einfachich)\
**Post date:** [12. Juli 2018 um 12:19 UTC](https://forum.shopware.com/t/tipps-fur-folgenden-fehler-uncaught-typeerror-overrideplugin-is-not-a-function/54041/5 "2018-07-12T12:19:49Z")

</div>

Mhm, ich benutze noch die 5.0.2, aber da ist es noch ungefair das gleiche:

&nbsp;

Egal was ich mache, aber finde absolut nicht den Fehler :-(&nbsp;

- der pfad in&nbsp;`$javascript`&nbsp;ist implizit relativ zu&nbsp;`frontend/_public/`&nbsp;(grauenhaft!) - Wird aber doch so überall angegeben.

Lg Tobias

---

<div class="post-metadata">

**Author:** ![paule76](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@paule76](https://forum.shopware.com/u/paule76)\
**Post date:** [12. Dezember 2018 um 09:30 UTC](https://forum.shopware.com/t/tipps-fur-folgenden-fehler-uncaught-typeerror-overrideplugin-is-not-a-function/54041/6 "2018-12-12T09:30:23Z")

</div>

Schon mal mit async laden probiert?

```
window.addEventListener('load', onloadEvent, false);
function onloadEvent(){
    document.asyncReady(function() {
  $.overridePlugin('swSearch', {
         ......
​ });
    }
}

```

&nbsp;
