- Correct pagination on page load
authorymh <ymh.work@gmail.com>
Fri, 21 Jun 2013 17:09:03 +0200
changeset 27 d5f4dde387a9
parent 26 758b9289aa9a
child 28 5918a9d353d0
- Correct pagination on page load - Ensure that page range always contains valid page nb
src/jocondelab/static/jocondelab/js/jocondelab.js
src/jocondelab/templates/jocondelab/term_edit.html
src/jocondelab/utils.py
--- a/src/jocondelab/static/jocondelab/js/jocondelab.js	Fri Jun 21 15:20:24 2013 +0200
+++ b/src/jocondelab/static/jocondelab/js/jocondelab.js	Fri Jun 21 17:09:03 2013 +0200
@@ -155,3 +155,15 @@
     });
 }
 
+function init_edit_page(page) {
+    var values = $('#term-filter-form').serialize();
+    // add page
+    if(typeof(page) !== "undefined" && page) { 
+        values += "&page="+page;
+    }
+    $('#term-explorer-container').load(term_list_table_url, values, function() {
+        $('#term-list-table #term-'+term_id).addClass('currenttermline');
+    });
+
+}
+
--- a/src/jocondelab/templates/jocondelab/term_edit.html	Fri Jun 21 15:20:24 2013 +0200
+++ b/src/jocondelab/templates/jocondelab/term_edit.html	Fri Jun 21 17:09:03 2013 +0200
@@ -21,7 +21,7 @@
     $(document).ready(function(){
         init_term_events();
         init_filter_events();
-        $('#term-filter-form').submit();
+        init_edit_page('{{request.GET.page}}');
     });
     
     </script>
@@ -74,9 +74,11 @@
     <tr>
         <td>{% trans 'alternative labels' %}</td>
         <td>
+            <ul>
             {% for label in term.alternative_labels_list %}
-                <div>{{ label }}</div>
+                <li>{{ label }}</li>
             {% endfor %}
+            </ul>
         </td>    
     </tr>
     <tr>
--- a/src/jocondelab/utils.py	Fri Jun 21 15:20:24 2013 +0200
+++ b/src/jocondelab/utils.py	Fri Jun 21 17:09:03 2013 +0200
@@ -56,9 +56,10 @@
         prev = None
         res = []
         for i in sorted(ranges):
-            if prev and i-prev > 1:
-                res.append(0)
-            res.append(i)
-            prev = i
+            if 1 <= i <= self.paginator.num_pages:
+                if prev and i-prev > 1:
+                    res.append(0)
+                res.append(i)
+                prev = i
         return res
     
\ No newline at end of file