#template js help

16 messages · Page 1 of 1 (latest)

eager yoke
#

okay so i made a custom collapsible container because its fun, but it only works in the template page, and not the articles that use the template, why isnt it working?

celest solar
#

Would it work if you removed "#Redirects" from the TargetPages?

eager yoke
#

yeah i did that, but it still yielded the same result

celest solar
tranquil gull
#

You need to debug your code. A common approach is to find what exactly is not working, and then you can fix this and test again.

For example:
Try temporarily replacing the page name check with true: does it work then? If so, try console.logging the wgPageName and seeing what it actually is. It's possible it's not exactly what you expected.

tranquil gull
#

If you want I can go check it on your wiki (post a link if so please) to give you an exact fix, but since you're doing it for fun I'm giving a hint pupCoffeeMH

#

Also, instead of checking for page name, checking if an element with a certain class/id specific to collapsibles is present is more universal. This way you don't have to update the JS every time you use the template on a new page.

lilac kestrel
tranquil gull
#

Yeah we discussed this earlier and Verdessence wanted to have some fun programming it themselves as far as I'm aware pupCoffeeMH

eager yoke
#

just replaced the if statement to true, and yeah it works, feel like its a band aid solution tbh but yeah it works -- might go check all the values in mw.config so it'll take a while

i've used mw-collapsible before, i know that ive installed it incorrectly but it works regardless, but learning to js is fun though

tranquil gull
#

It's not supposed to be a fix but a step in debugging (see my previous message for further steps). See, this means the original check always returns false with your values, which means your page name list has page names in a wrong format or you're not checking the current page name correctly. Which one is it I can't tell, but using console.log with related values and seeing the result in the devtools console will quickly tell you pupCoffeeMH
It's a common thing to do then things don't work in js.

#

(If you wanted to treat it as a fix you would remove the if statement completely because if(true) always runs)

eager yoke
#

yeah im stumped on this one, console.logging the wgpagename results to printing the page name of an article, so maybe my code didn't.... maybe it's just only basing on the page name rather than the present .collapsible css then?

#

i'll review

#

oh shit it works!

#

guess this is a job well done then, thanks for your input guys