work on homepage

This commit is contained in:
2019-06-09 19:55:23 +02:00
parent 647e333a16
commit 027ad5511c
17 changed files with 396 additions and 381 deletions

View File

@@ -1,40 +1,40 @@
jQuery(function ($) { // use jQuery code inside this to avoid "$ is not defined" error
$('.misha_loadmore').click(function () {
// $('.misha_loadmore').click(function () {
var button = $(this),
data = {
'action': 'loadmore',
'query': misha_loadmore_params.posts, // that's how we get params from wp_localize_script() function
'page': misha_loadmore_params.current_page
};
button.trigger("moreload-start")
console.log(misha_loadmore_params)
// var button = $(this),
// data = {
// 'action': 'loadmore',
// 'query': misha_loadmore_params.posts, // that's how we get params from wp_localize_script() function
// 'page': misha_loadmore_params.current_page
// };
// button.trigger("moreload-start")
// console.log(misha_loadmore_params)
$.ajax({ // you can also use $.post here
url: misha_loadmore_params.ajaxurl, // AJAX handler
data: data,
type: 'POST',
beforeSend: function (xhr) {
// $.ajax({ // you can also use $.post here
// url: misha_loadmore_params.ajaxurl, // AJAX handler
// data: data,
// type: 'POST',
// beforeSend: function (xhr) {
button.html('<p>Betöltés...</p>'); // change the button text, you can also add a preloader image
},
success: function (data) {
if (data) {
// button.html('<p>Betöltés...</p>'); // change the button text, you can also add a preloader image
// },
// success: function (data) {
// if (data) {
button.html('<a>Tovább</a>').before(data); // insert new posts
misha_loadmore_params.current_page++;
button.trigger("moreload-finish")
// button.html('<a>Mutass többet</a>').before(data); // insert new posts
// misha_loadmore_params.current_page++;
// button.trigger("moreload-finish")
if (misha_loadmore_params.current_page -1 == misha_loadmore_params.max_page)
button.remove(); // if last page, remove the button
// if (misha_loadmore_params.current_page -1 == misha_loadmore_params.max_page)
// button.remove(); // if last page, remove the button
// you can also fire the "post-load" event here if you use a plugin that requires it
// $( document.body ).trigger( 'post-load' );
} else {
button.remove(); // if no data, remove the button as well
}
}
});
});
// // you can also fire the "post-load" event here if you use a plugin that requires it
// // $( document.body ).trigger( 'post-load' );
// } else {
// button.remove(); // if no data, remove the button as well
// }
// }
// });
// });
});