Topic on Project:Support desk

[RESOLVED] Custom Javascript is not loading

9
PrashantB (talkcontribs)

Hello There,

I am trying to load custom JavaScript file using following code.

$wgResourceModules['skins.alskin01'] = array(
	'scripts' => array('alskin01.resources.main.js','alskin01/resources/some.js'),
    'remoteBasePath' => &$GLOBALS['wgStylePath'],
	'localBasePath' => &$GLOBALS['wgStyleDirectory']  
);

The alskin01 is folder inside "skins" folder. The resources is folder inside "alskin01" folder. Where as main.js and some.js are my custom Javascript file. It will be great if you could help me understand where these files get loaded and how to access JS functions.

Florianschmidtwelzow (talkcontribs)

Hello!

What's this?

array('alskin01.resources.main.js','alskin01/resources/some.js')

That doesn't make sense, or do you have ...main.js in your skin root folder and some.js in alskin01/resources?

Where do you load the module skins.alskin01? What does the console say?

> how to access JS functions

Where you want to access what?

PrashantB (talkcontribs)

Hello,

The main.js and some.js files are located in alskin01/resources folder which is my custom skin folder. I want to use the main.js file as my source of interactivity for my custom skin. Currently, I am adding or laying out my design in ALSkin01.skin.php file. In ALSkin01.skin.php file I want to take a help from main.js file from interactivity functionality perspective. For that matter I am adding JS file in $wgResourceModules. Which is a part of ALSkin01.php file. FYI:

  • I followed the step mentioned in Manual Skinning
  • My MediaWiki version is 1.23.1
  • I corrected my mistake 'scripts' => array('alskin01/resources/main.js','alskin01/resources/awesome.js')
Florianschmidtwelzow (talkcontribs)

Ok, and now check, if you load the module, like explained in this section of Manual:Skinning:

public function initPage( OutputPage $out ) {
	parent::initPage( $out );
	$out->addModules( 'skins.alskin01' );
}
PrashantB (talkcontribs)

I already added that line of code. I am wondering, how that script get loaded and how to access the function from JS file.

Florianschmidtwelzow (talkcontribs)

I don't understand, what you mean :) If you follow the manual, you simply can use the JS functions you defined :)

PrashantB (talkcontribs)

Issue has been resolved, sorry for trouble.

Florianschmidtwelzow (talkcontribs)

Maybe you can give more details what you solved how? So others can read your solution and maybe it helps to solve the problems of these people, too? :)

PrashantB (talkcontribs)

I made very stupid mistake, the $wgDefaultSkin was set to other customised skin and not to the skin where I am working.

Reply to "[RESOLVED] Custom Javascript is not loading"