Publishing a post with Jquery
-
I am writing a plugin where a click on the publish button is intercepted with jQuery in the admin. After clicking operations are performed using a timer to prevent timeouts. At the end of the operation it submits the form using jQuery(‘form#post’).submit(); . This works, but it is saving as a draft not as published.
Does anyone know how to submit the post form with jQuery and publish the page?
The complete code is below:
jQuery("#publish").click(function(event){ if( jQuery('#table_constructor').length==0) { return true; } jQuery('#preview_window').fadeOut('fast'); //add top jQuery('#table_constructor #post_content').val('<table>'); //use timer to progressively transfer rows var c=0; var num=jQuery('#preview_window table tr').length; var addRowIntval = setInterval(function(){add_input_data()}, 2); jQuery('#loading_bar').remove(); jQuery('#table_constructor').prepend('<div id="loading_bar"><h1>Saving Table</h1><div id="bar"><div id="meter" style="width:0"></div></div>'); function add_input_data(){ //adjust progress bar var per=c/num*100; jQuery('#meter').width(per+'%'); //append table var v=jQuery('#table_constructor #post_content').val(); var tr=jQuery('#preview_window table tr:eq('+c+')').clone().wrap('<p>').parent().html(); jQuery('#table_constructor #post_content').val(v+tr); c++; //finish if(c>num){ clearInterval(addRowIntval); jQuery('#table_constructor #post_content').val(v+TableLegs); // jQuery('#loading_bar').remove(); addAlternating_color(); jQuery('form#post').submit(); } } event.stopImmediatePropagation(); return false; });
Thank you
E
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Publishing a post with Jquery’ is closed to new replies.