On Mon, 02 Dec 2013 16:33:25 +0100, Daniel Barrett danb@vistaprint.com 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-wiki...
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....
* Firing it from the previewer: https://github.com/wikimedia/mediawiki-core/blob/master/resources/mediawiki....
** (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.... )