我有一个过滤器表单,它使用来自数据库的新过滤结果填充容器div(#results)。但更改过滤器后Infinite Ajax Scroll插件显示第二页第一次搜索的结果。在更改事件中,我需要完全重置旧结果并仅显示新结果。我尝试了很多解决方案,但都没有做完我知道methods这样做,但我不明白如何在我的代码中使用它们(查看注释)。重置无限滚动以显示通过AJAX检索到的新结果
// Form select inputs: on change call the filter
$("select").on("change", function() {
setTimeout(function() {
ias.destroy();
}, 1000);
ias.bind();
filter();
});
// Filter: Ajax call that returns new results by a SQL query to the DB
var filter = function() {
var formData = form.serializeObject();
$.ajax({
url: "/libs/filterData.php",
type: "POST",
data: JSON.stringify(formData),
cache: false,
success: function(results) {
$("#results").html(results);
}
});
};
// IAS configuration
//var initializeIas = function() {
var ias = jQuery.ias({
container: "#results",
item: ".result",
pagination: ".page-nav",
next: ".page-nav a"
});
//};
//initializeIas();
也试过this solution但不起作用。
类似的问题here。
的http://stackoverflow.com/q/20404493/932282 – mhu
可能重复我尝试这个解决方案http://stackoverflow.com/一个/ 22093845,因为其他人是旧的,现在有插件的版本2。它不工作...(检查上面更新的代码) –