Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endless pagination loading entire page on second page after scroll #48

Closed
devanasrikanth opened this issue Apr 26, 2013 · 9 comments
Closed

Comments

@devanasrikanth
Copy link

Hi,

i am using twitter style django end less pagination on my website.
On the homepage, the endless pagination works fine and no problems there.
But on the different category page, it is loading the entire page on the second page just with second page items. I am clueless why it is happening only on the category pages and not on the homepage.
It looks like request.is_ajax() is not working when i scroll to second page and reloading the entire page.

Can anyone help?

Thanks

@devanasrikanth
Copy link
Author

After several attempts, i have delete all the caching and restarted the apache and it all works fine now.

@ubehera
Copy link

ubehera commented Apr 4, 2014

I have the same issue, but I'm running on localhost. Can you please explain how you did the request.is_ajax() ? Also, I'm using class based generic views.

@devanasrikanth
Copy link
Author

My view looks like below.

def homepage(request):
template = 'homepage.html'
page_template = 'home_page_index.html'

if request.is_ajax():
    template = page_template

return render_to_response(template,
                    {'page_template': page_template,
                    },
                    context_instance=RequestContext(request))

And my Homepage.html looks like below.

        {% include page_template %}
        <script src="{{ STATIC_URL }}endless_pagination/js/endless-pagination.js"></script>
        <script>
            $.endlessPaginate({paginateOnScroll: true, 
                                   paginateOnScrollMargin: 250
                                   });
        </script>

And my home_page_index.html has the actual content that needs to be in pageless scrolling.

@ubehera
Copy link

ubehera commented Apr 5, 2014

But what if you have multiple paginations, and using the decorator is not an option.

@devanasrikanth
Copy link
Author

Are you saying that you want to pass different page_template to the same view depending on the area in your site you need scrolling ?

@ubehera
Copy link

ubehera commented Apr 5, 2014

Correct, like 3 multiple paginations on same view. Using class based generic views right now, but can change to function based views if CBV not an option.

@devanasrikanth
Copy link
Author

If there is any way you can recognise the different paginations inside the view, then I think you can write a condition like below inside the view.

if request.is_ajax():
if (pagination1)
template = page_template_1
elif (pagination2)
template = page_template_2

@ubehera
Copy link

ubehera commented Apr 5, 2014

I tried to pull the 'querystring_key' from the request for exactly that purpose, but no luck so far. Not sure if it's the same as the "paginate using 'x'".

@devanasrikanth
Copy link
Author

I don't think I can help any further without knowing exactly how your page and code looks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants