This might be a typo in your message, but it's jQuery, not jquery. Also you can shorten that page ready code, see: http://learn.jquery.com/using-jquery-core/document-ready/
By default, jQuery and it's alias $ are always available in MediaWiki. However, we often tend to import globals and then redefine $ and mw as function parameters. This is called the 'module pattern'. http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html You can find a practical example of it here for instance: https://github.com/wikimedia/mediawiki-extensions-3D/blob/master/modules/ext...
Note also that when inserting something regarding the content (which i suspect you are), then we usually use mw.hook('wikipage.content').add(function( content ) {} ), where content will give you the DOM collection of just the rendered page content. This helps when partial page updates occur, as with the Visual editor or the JS based previews of a page, which do not necessarily open a new page.
DJ
On Wed, Mar 14, 2018 at 1:15 PM, Sigbert Klinke sigbert@wiwi.hu-berlin.de wrote:
Hi,
I try to use JQuery code in tag extension. Following the manuals I added in extension.json:
"ResourceModules": { "ext.Iframe" : { "scripts": [ "modules/ext.Iframe.js" ] } },
in my main.php file:
class IFrame {
public static function renderIframe( $str, array $argv, Parser $parser, PPFrame $frame ) { ... $parser->mOutput->addModules('ext.Iframe'); ... }
... }
and my modules/ext.Iframe.js looks like:
jquery(document).ready(function ($) { $(document.body).append("Hello World!"); });
I would have expected to see a "Hello World!" at the end of my wiki page, but nothing appears.
So I missed something. Any ideas what?
Thanks in advance
Sigbert
-- https://hu.berlin/sk https://hu.berlin/mmstat3
MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l