FANDOM


Nuvola apps kservices This article is about a system or feature that is no longer in use.
  • The page is retained for historical reasons.

It's not particularly elegant but every once in a while it's necessary to load JavaScript with a verbatim tag. Verbatim'ed code faces a few challenges though. It gets loaded before the MediaWiki variables and before jQuery. It's practically running naked. This library tries to solve that problem. It provides a single method - dev.verbatim.ready - that attempts to fully replace $(document).ready()

Further testing is required, but this code does seem to work under the wikiamobile skin as well. Do not however expect the two parameters to the callback to be defined! The mediaWiki JS does not seem to get loaded. At all. And jQuery Mobile is not accessible under the alias jQuery but only as $. Still, jQuery should be available when dev.verbatim.ready fires.

dev.verbatim.ready

stand in for jQuery's ready method for verbatim'ed code
dev.verbatim.ready(callback);
parameter:
callback function
to be called when the document is ready
returns:
nothing
throws:
Error if callback is not a function
The callback gets executed when
  • the DOM has fully loaded and can be manipulated
  • the MediaWiki code has loaded and
  • jQuery has loaded

If the method is called after the ready event, the callback will be executed immediately.

The callback receives two parameters:

  1. the mediaWiki object and the
  2. the jQuery object
dev.verbatim.ready(function (mw, $) {
    $('#username').text(mw.config.get('wgUserName'));
});


Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.