0

I'm trying to add a JQuery plugin which is not one of core plugins of mediawiki (twbsPagination)

The problem is mw.loader.using doesn't support URL so I can't pass url of twbsPagination to be loaded & mw.loader.load doesn't support callback to make me able to run my code after loading the plugin.

How can I load a jquery plugin and use it after the load in mediawiki 1.28 ?

Ariyan
  • 14,760
  • 31
  • 112
  • 175

1 Answers1

0

To the best of my knowledge, you can't add to the list of what mw.loader.load or mw.loader.using support, but you can still use $.getScript() without loading anything extra, since jQuery itself comes as part of the default Mediawiki install. If you have cascading dependencies, such as a script that makes use of a $.getScript()-loaded plugin, simply nest each level of dependency inside the $.getScript().complete() callbacks just as you would with the callback you'd give mw.loader.using.

As a side note, using $.getScript to load javascript on pages outside of Common.js also allows you to use ES6 in those non-Common.js scripts. (Mediawiki still doesn't support ES6 on Common.js.)

For a live example, look at lines ~306-335 in https://stratics.com/w/index.php?title=MediaWiki:Common.js

BrianFreud
  • 7,094
  • 6
  • 33
  • 50