On Mon, 02 Dec 2013 16:33:25 +0100, Daniel Barrett <[email protected]> wrote:

Some of our custom wiki extensions use AJAX to render article content. This content renders fine with the 
standard "Show Preview" button but not with the AJAX-based "Preview" tab 
("side-by-side preview" in Preferences). I imagine the problem is due to order of operations.

Is there some standard code I should add to my AJAX-based extensions (say, 
waiting for some event?) so things render in the right order and display 
correctly in the side-by-side preview mode?

Yes, starting with MediaWiki 1.22, the 'wikipage.content' mw.hook. (And the 
mw.hook framework in general.)

https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.hook-event-wikipage_content

You can see it used in the AJAX page preview functionality we have in core:

* Registering a hook handler: 
https://github.com/wikimedia/mediawiki-core/blob/master/resources/mediawiki.page/mediawiki.page.ready.js#L4-L25

* Firing it from the previewer: 
https://github.com/wikimedia/mediawiki-core/blob/master/resources/mediawiki.action/mediawiki.action.edit.preview.js#L90

** (The hook is also fired on page load, and that's where it is documented: 
https://github.com/wikimedia/mediawiki-core/blob/master/resources/mediawiki.page/mediawiki.page.startup.js#L19-L24
 )


--
Matma Rex

_______________________________________________
MediaWiki-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to