- page.load( target + ' ' + copySelector, postData,
- function() {
-
- for( var i=0; i<copyElements.length; ++i) {
- // For all the specified elements, find the elements in the loaded page
- // and the real page, empty the element in the real page, and fill it
- // with the content of the loaded page
- var copyContent = page.find( copyElements[i] ).contents();
- $(copyElements[i]).empty().append( copyContent );
- var newClasses = page.find( copyElements[i] ).prop('class');
- $(copyElements[i]).prop( 'class', newClasses );
- }
-
- $.each( copyElements, function( k, v ) {
- // Don't belligerently show elements that are supposed to be hidden
- $( v ).fadeTo( 'fast', 1, function() {
- $( this ).css( 'display', '' );
- } );
- } );
-
- loadSpinner.remove();
-
- $( mw ).trigger( 'LivePreviewDone', [copyElements] );
- } );
+ // gather all the data from the form
+ var postData = $( '#editform' ).formToArray(); // formToArray: from jquery.form
+ postData.push( { 'name' : e.target.name, 'value' : '1' } );
+
+ // load new preview data
+ // FIXME this should use the action=parse API instead of loading the entire page
+ $previewDataHolder.load( target + ' ' + copySelectors.join( ',' ), postData, function() {
+ // Copy the contents of the specified elements from the loaded page to the real page.
+ // Also copy their class attributes.
+ for ( var i = 0; i < copySelectors.length; i++ ) {
+ var $from = $previewDataHolder.find( copySelectors[i] );
+ var $to = $( copySelectors[i] );
+
+ $to.empty().append( $from.contents() );
+ $to.attr( 'class', $from.attr( 'class' ) );
+ }
+
+ $loadSpinner.remove();
+ $copyElements.animate( { 'opacity': 1 }, 'fast' );
+
+ $( mw ).trigger( 'LivePreviewDone', [copySelectors] );
+ } );