treeview element ids should be unique, cleanup 3.5
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 01 Sep 2009 18:44:17 +0200
branch3.5
changeset 3079 c1a4fbf2539a
parent 3076 71ab8d47c57b
child 3080 32c2b6a34ab2
treeview element ids should be unique, cleanup
web/data/cubicweb.widgets.js
web/views/treeview.py
--- a/web/data/cubicweb.widgets.js	Tue Sep 01 16:55:45 2009 +0200
+++ b/web/data/cubicweb.widgets.js	Tue Sep 01 18:44:17 2009 +0200
@@ -181,13 +181,6 @@
     }
 }
 
-Widgets.TreeView = defclass("TreeView", null, {
-    __init__: function(wdgnode) {
-	jQuery(wdgnode).treeview({toggle: toggleTree,
-				  prerendered: true});
-    }
-});
-
 
 /* widget based on SIMILE's timeline widget
  * http://code.google.com/p/simile-widgets/
--- a/web/views/treeview.py	Tue Sep 01 16:55:45 2009 +0200
+++ b/web/views/treeview.py	Tue Sep 01 18:44:17 2009 +0200
@@ -32,13 +32,17 @@
             if treeid is None:
                 self.warning('Tree state won\'t be properly restored after next reload')
                 treeid = make_uid('throw away uid')
-        self.w(u'<ul id="tree-%s" class="%s">' % (treeid, self.css_classes))
+        toplevel_thru_ajax = self.req.form.pop('treeview_top', False)
+        toplevel = toplevel_thru_ajax or (initial_load and not self.req.form.get('fname'))
+        ulid = ' '
+        if toplevel:
+            ulid = ' id="tree-%s"' % treeid
+        self.w(u'<ul%s class="%s">' % (ulid, self.css_classes))
         for rowidx in xrange(len(self.rset)):
             self.wview(self.itemvid, self.rset, row=rowidx, col=0,
                        vid=subvid, parentvid=self.id, treeid=treeid)
         self.w(u'</ul>')
-        toplevel_thru_ajax = self.req.form.pop('treeview_top', False)
-        if (initial_load and not self.req.form.get('fname')) or toplevel_thru_ajax:
+        if toplevel:
             self.req.add_css('jquery.treeview.css')
             self.req.add_js(('cubicweb.ajax.js', 'cubicweb.widgets.js', 'jquery.treeview.js'))
             self.req.html_headers.add_onload(u"""