django endless pagination(twitter style) not working - .endless_more class not in html but used in js

StackOverflow https://stackoverflow.com/questions/12942047

Вопрос

i am using django endless pagination . its working normally that just shows the numbers at the bottom .

but, i tried to integrate twitter style into it:

http://django-endless-pagination.readthedocs.org/en/latest/twitter_pagination.html#pagination-on-scroll

I have followed exactly but didnt work .

When I looked at the js code, i have seen they have used .endless_more in js class, but the generated html file has only two classes for links :

1)endless_page_current
2)endless_page_link

but they used a.endless_more in js.

Can you tell me the correct way to implement?

Thanks

Views :

from endless_pagination.decorators import page_template
@page_template("my_index_page.html")
def myview(request,template='my_index.html', extra_context=None):
  data = {}
 if extra_context is not None:
     data.update(extra_context)

 myobj = Myobj.objects.all()
 data['myobj'] = myobj
 return render_to_response(template, data, context_instance=RequestContext(request))

Template :

my_index.html

 <script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="{{ STATIC_URL }}js/endless.js"></script>
<script src="{{ STATIC_URL }}js/endless_on_scroll.js"></script>
 {% include page_template %}

my_index_page.html

 {% load templatetags %}
<center>
<div>
{% load endless %}
{% paginate myobj %}
{% for obj in myobj %}

 {{  obj.name }}


 {% endfor %}

 {% show_pages %}

  </div> 
 <center>

Here, I seriously beleive that i need to add some classes like endless_more , which the django-endless-documentation missed.

Это было полезно?

Решение

i'm using that on my portal, and it seems fine your code, you just missed one thing

{% show_more %}

that's what actually enables the twitter-style infinite pagination

edit here:

you may want to add this too:

<script type="text/javascript" charset="utf-8">
    var endless_on_scroll_margin = 20;
</script>

where "20" is the number of pixels (from the bottom of the page) that triggers the scrolling

you may want to try more than one value till you get the perfect one for your project

see here and here

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top