Backout "[web/navigation] use add_onload instead of inline javascript href" stable
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 24 Mar 2014 16:29:18 +0100
branchstable
changeset 9587 0f0199948f93
parent 9586 121c88b360d0
child 9588 fe267b7336f3
Backout "[web/navigation] use add_onload instead of inline javascript href" This reverts changeset 170e1437948d, for at least two reasons: the PageNavigationSelect component was not updated for the new type of navigation links, and external cubes defining View.page_navigation_url exist in the wild and also got broken navigation links. This reopens #3501626 and closes #3677945.
web/component.py
web/views/navigation.py
--- a/web/component.py	Fri Mar 14 10:51:05 2014 +0100
+++ b/web/component.py	Mon Mar 24 16:29:18 2014 +0100
@@ -108,8 +108,12 @@
         view = self.cw_extra_kwargs.get('view')
         if view is not None and hasattr(view, 'page_navigation_url'):
             url = view.page_navigation_url(self, path, params)
+        elif path in ('json', 'ajax'):
+            # 'ajax' is the new correct controller, but the old 'json'
+            # controller should still be supported
+            url = self.ajax_page_url(**params)
         else:
-            url = self.ajax_page_url(**params)
+            url = self._cw.build_url(path, **params)
         # XXX hack to avoid opening a new page containing the evaluation of the
         # js expression on ajax call
         if url.startswith('javascript:'):
@@ -118,9 +122,9 @@
 
     def ajax_page_url(self, **params):
         divid = params.setdefault('divid', 'pageContent')
-        params['fname'] = 'view'
         params['rql'] = self.cw_rset.printable_rql()
-        return self._cw.build_url('ajax', **params)
+        return js_href("$(%s).loadxhtml(AJAX_PREFIX_URL, %s, 'get', 'swap')" % (
+            json_dumps('#'+divid), js.ajaxFuncArgs('view', params)))
 
     def page_link(self, path, params, start, stop, content):
         url = xml_escape(self.page_url(path, params, start, stop))
--- a/web/views/navigation.py	Fri Mar 14 10:51:05 2014 +0100
+++ b/web/views/navigation.py	Mon Mar 24 16:29:18 2014 +0100
@@ -55,7 +55,6 @@
 from logilab.mtconverter import xml_escape
 from logilab.common.deprecation import deprecated
 
-from cubicweb.utils import json_dumps
 from cubicweb.predicates import paginated_rset, sorted_rset, adaptable
 from cubicweb.uilib import cut
 from cubicweb.view import EntityAdapter
@@ -281,13 +280,6 @@
     nav = req.vreg['components'].select_or_none(
         'navigation', req, rset=rset, page_size=page_size, view=view)
     if nav:
-        domid = getattr(view, 'domid', 'pageContent')
-        view._cw.add_onload('''
-        jQuery('div.displayAllLink a, div.pagination a').click(function() {
-            cw.jqNode(%s).loadxhtml(this.href, null, 'get', 'swap');
-            return false;
-        });
-            ''' % json_dumps(domid))
         if w is None:
             w = view.w
         if req.form.get('__force_display'):