web/views/treeview.py
changeset 187 cae87ca76f02
parent 150 1190261a1f13
child 237 3df2e0ae2eba
--- a/web/views/treeview.py	Mon Dec 08 14:47:07 2008 +0100
+++ b/web/views/treeview.py	Mon Dec 08 17:48:20 2008 +0100
@@ -22,8 +22,14 @@
         css_classes = 'treeview widget'
         if self.fstree:
             css_classes += ' filetree'
-        self.w(u'<ul class="%s" cubicweb:loadtype="auto" cubicweb:wdgtype="TreeView">'
-               % css_classes)
+        # XXX noautoload is a quick hack to avoid treeview to be rebuilt
+        #     after a json query and avoid double toggling bugs.
+        #     Need to find a way to do that cleanly.
+        if 'noautoload' in self.req.form:
+            self.w(u'<ul class="%s" cubicweb:wdgtype="TreeView">' % css_classes)
+        else:
+            self.w(u'<ul class="%s" cubicweb:loadtype="auto" cubicweb:wdgtype="TreeView">'
+                   % css_classes)
         for rowidx in xrange(len(self.rset)):
             self.wview(self.itemvid, self.rset, row=rowidx, col=0,
                        vid=subvid, parentvid=self.id)
@@ -97,7 +103,8 @@
             rql = entity.children_rql() % {'x': entity.eid}
             url = html_escape(self.build_url('json', rql=rql, vid=parentvid,
                                              pageid=self.req.pageid,
-                                             subvid=vid))
+                                             subvid=vid,
+                                             noautoload=True))
             cssclasses.append('expandable')
             divclasses = ['hitarea expandable-hitarea']
             if is_leaf :