1jQuery(function() { 2 3 var forms = jQuery('.plugin_log'); 4 5 if (forms.length === 0) { 6 return; 7 } 8 9 function handleEvent( form ) { 10 var loading; 11 var ajax = new jQuery.ajax({ 12 'type': 'post', 13 'url': form.action, 14 'data': jQuery( form ).serialize(), 15 'success': function( data ){ 16 var rootTag = jQuery('<root>'); 17 jQuery(data).appendTo(rootTag); 18 var listitem = rootTag.find('.dokuwiki form.plugin_log').parents('ul').find('li:eq(1)'); 19 20 jQuery( form ) 21 .parents( 'li' ) 22 .after( listitem ) 23 .find( '.edit' ).val( '' ); 24 25 loading && loading.remove() 26 }, 27 'error': function(){ 28 alert(this.response); 29 loading.remove(); 30 } 31 }); 32 loading = jQuery('<img/>', { 33 'src': DOKU_BASE+'lib/images/throbber.gif', 34 'alt': '...', 35 'class': 'load', 36 'css': { 37 'margin-bottom': '-5px' 38 } 39 }).appendTo( form ) 40 } 41 42 jQuery( forms ).each(function(idx, el){ 43 var el = el; 44 jQuery( el ).find( '.button' ).click(function(e){ 45 e.preventDefault(); 46 handleEvent( el ); 47 }) 48 }) 49}); 50