1jQuery(function($){ // use jQuery code inside this to avoid "$ is not defined" error 2 $('.kk_lichter_loadmore').click(function(){ 3 4 5 var button = $(this); 6 var cur_page = button.attr('data-current_page'); 7 var cur_page_id = '#load-'+cur_page; 8 var multi_loaded = ''; 9 if($(cur_page_id).length ){ 10 multi_loaded = $(cur_page_id).attr('data-posts_loaded'); 11 } 12 if(multi_loaded != ''){ 13 var data = { 14 'action': 'loadmore', 15 'query': kk_lichter_loadmore_params.posts, // that's how we get params from wp_localize_script() function. 16 // 'page' : button.attr('data-current_page'), 17 'page' : cur_page, 18 // 'loaded' : button.attr('data-posts_loaded'), 19 'loaded' : multi_loaded, 20 // 'max_page' : button.attr('data-max_page') 21 'max_page' : kk_lichter_loadmore_params.max_page 22 }; 23 } else { 24 var data = { 25 'action': 'loadmore', 26 'query': kk_lichter_loadmore_params.posts, // that's how we get params from wp_localize_script() function. 27 // 'page' : button.attr('data-current_page'), 28 'page' : kk_lichter_loadmore_params.current_page, 29 // 'loaded' : button.attr('data-posts_loaded'), 30 'loaded' : kk_lichter_loadmore_params.loaded, 31 // 'max_page' : button.attr('data-max_page') 32 'max_page' : kk_lichter_loadmore_params.max_page 33 }; 34 } 35 36 $.ajax({ // you can also use $.post here 37 url : kk_lichter_loadmore_params.ajaxurl, // AJAX handler 38 data : data, 39 type : 'POST', 40 beforeSend : function ( xhr ) { 41 button.text('Einen Moment bitte...'); // change the button text, you can also add a preloader image 42 }, 43 success : function( data ){ 44 if( data ) { 45 button.text( 'Weitere Lichter anzeigen' ).prev().append(data); // insert new posts 46 kk_lichter_loadmore_params.current_page++; 47 button.attr('data-current_page', kk_lichter_loadmore_params.current_page); 48 // button.attr('data-posts_loaded', kk_lichter_loadmore_params.loaded); 49 console.log(kk_lichter_loadmore_params.loaded); 50 console.log(multi_loaded); 51 52 if ( button.attr('data-current_page') == kk_lichter_loadmore_params.max_page ) { 53 button.remove(); // if last page, remove the button 54 } 55 56 // you can also fire the "post-load" event here if you use a plugin that requires it 57 // $( document.body ).trigger( 'post-load' ); 58 } else { 59 button.remove(); // if no data, remove the button as well 60 console.log(multi_loaded + ' Letzte Seite geladen!'); 61 } 62 } 63 }); 64 }); 65});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.