Infinite scroll plugin modify the path with custom query

无人久伴 提交于 2019-12-03 15:37:50

Ok so I had to do a little hack but I got it working for my needs thanks to Rich for pointing me to the related question.

I added some additional properties to the jquery.infinitescroll.js prototype here:

//line 67
 $.infinitescroll.prototype = {
       //My custom parameters
        pageType: "&type=items",
        categoryParam: "&category=shoes",
        /*  
            ----------------------------
            Private methods
            ----------------------------
            */

Then inside the function called:

retrieve: function infscr_retrieve(pageNum) {}

there is a variable:

desturl = path.join(opts.state.currPage)

Changed it to

desturl = path.join(opts.state.currPage + $.infinitescroll.prototype.pageType + $.infinitescroll.prototype.categoryParam);

This will add your additional query parameters at the end of the desturl.

Then from you page where you have you JavaScript you can do something like this:

$('#filters a').click(function () {
    $.infinitescroll.prototype.pageType = "&type=products" ;                  
    $.infinitescroll.prototype.pageType = "&category=clothes";                           
     return false;
});

This will update the query parameters of the next page with you custom queries.

Hope this will help someone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!