LivePreview: bind a delegated click event for #wpPreview/Diff
authorAndrew Garrett <agarrett@wikimedia.org>
Sat, 15 Sep 2012 14:14:27 +0000 (16:14 +0200)
committerMatmaRex <matma.rex@gmail.com>
Sun, 16 Sep 2012 12:35:40 +0000 (14:35 +0200)
This makes it work with edit forms added to the page after it is loaded,
e.g. by an extension (like LiquidThreads).

Change-Id: Ia9673a754c871baea82bb28ded7b19e2608d9d03

skins/common/preview.js

index c88272d..5b5a3c6 100644 (file)
                // (mw.loader takes care of stuff if they happen to be loaded already)
                mw.loader.load( 'mediawiki.action.history.diff' );
 
-               $( '#wpPreview, #wpDiff' ).click( doLivePreview );
+               $( document.body ).on( 'click', '#wpPreview, #wpDiff', doLivePreview );
        } );
 } )( mediaWiki, jQuery );