Content deleted Content added
fix errors |
further comments |
||
Line 46:
// See also: https://www.mediawiki.org/wiki/ResourceLoader/Developing_with_ResourceLoader#Client-side_.28dynamically.29
// Example
// Run only on view (not edit) pages. See [[mw:Manual:Interface/JavaScript#Page-specific]]
if ( mw.config.get('wgAction') === 'view' ) {
mw.hook( 'wikipage.content').add( function ($contents) {▼
// Attach a function to be run once the 'wikipage.content' part of a page is available
▲ mw.hook( 'wikipage.content').add( function ($contents ) {
// Like document.ready, this will run, once that part of the page is
// ready/updated.
// $contents is a jQuery list of DOM elements, that has just become available.
// See also: http://api.jquery.com/jquery/
// Get all the <li> elements from $contents, but skip those with a class or ID,
// because they might have special functionality that you don't want to break.
// We generally avoid things like this, because they will break easily.
// Wikipedia is so diverse and big, that to do anything,
// your content really needs a class or ID.
|