Django admin - jQuery namespace

后端 未结 3 487
故里飘歌
故里飘歌 2021-01-18 01:14

I\'m trying to use certain jQuery plugins in my Django admin site.

Django admin sets the jQuery namespace to django.jQuery (to avoid conflicts)

3条回答
  •  失恋的感觉
    2021-01-18 01:55

    Actually, most plugins will require "jQuery" - not $ - to be available, and then provide $ themselves as in dmidz's answer.

    Therefore, insert

    var jQuery = django.jQuery;
    

    before your external references. If you're loading a bunch of thirdparty jQuery plugins, put the above line in a script tag that preceeds the plugins.

    See also my question five months ago How to provide $ to third-party, external jQuery plugins in Django admin

提交回复
热议问题