0

I have a bit unusual case in my project. The jQuery is loaded under a namespace, like

var grp = {
    "jQuery": jQuery.noConflict(true)
};

So in my custom scripts I am doing:

(function($){...}(grp.jQuery);

The question I have is how to handle external jQuery plugins. E.g. I want to add autocomplete plugin, which depends on jQuery, and starts with

$(document).ready(function() { ....

And it looks like the only option to include them in source code like

<script type="text/javascript" src="/static/autocomplete_light/django_admin.js"></script>

would be to edit them all, which is not practical...

1
  • 1
    I can't understand what is your question. Commented Mar 30, 2016 at 13:16

2 Answers 2

4

You have two options:

  1. Move jQuery to where the plugins expect to find it (i.e. to a global)
  2. Edit all the plugins to tell them where jQuery actually is

You could try writing a preprocessor that edits all the plugins for you at build time (this would probably be more work and more error prone than is worthwhile).

Sign up to request clarification or add additional context in comments.

Comments

0

Assuming you are not using the $ variable name anywhere else, maybe you can append it to the window on startup so it'll be available.

Something like:

(function(jQuery) {
    window.$ = jQuery;
}(grp.jQuery))

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.