Jump to content

Topic on User talk:Jdlrobson

Page Previews: wikipage.content hook

4
Enterprisey (talkcontribs)

Hi! I'm writing a user script that adds new links to a page, and would like to enable Page Previews handlers for those links. Per this change, it looks like the wikipage.content hook won't work, and I've been looking through the code and can't see any other way to do this. Would that be correct? (And sorry if this is the wrong venue - I wasn't sure opening a task on the Page-Previews phab workboard was a good idea.)

Jdlrobson (talkcontribs)

The delegate event handler we use means any link no matter when it is added will trigger a page preview so no hooks are needed here.

The link to be considered valid however must have a link and title attribute and an associated page preview associated with the URL. This code for example will trigger a page preview:

$('<a title="Hello" href="/wiki/Hello">hello</a>').prependTo('#mw-content-text')
Enterprisey (talkcontribs)

Thank you! I tried it, but I'm on a Special-namespace page. Will it only work in mainspace?

Jdlrobson (talkcontribs)
Reply to "Page Previews: wikipage.content hook"