Welcome + dijit layout (problem with middleware collector?)

27 views
Skip to first unread message

Ferran

unread,
Dec 2, 2010, 6:26:04 AM12/2/10
to dojang...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hello all;

This is my first time in this list, i've just starting using dojango to
beautify my django app, i'm also new to dojo.

I was trying to do a tab layout, and just added this to my template:

<div dojoType="dijit.layout.TabContainer">
<div id="tab1" dojoType="dijit.layout.ContentPane">a</div>
<div id="tab2" dojoType="dijit.layout.ContentPane">b</div>
</div>

But it seems DojoCollector middleware does not collect these.

Using dojango.middleware.DojoCollector:

dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.form.Select");
dojo.require("dijit.form.NumberTextBox");
dojo.require("dijit.form.DateTextBox");

using dojango.middleware.DojoAutoRequire:

dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.form.NumberTextBox");
dojo.require("dijit.form.Select");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.form.ValidationTextBox");

also DojoCollector uses doble line break, it seems.

I can't see my tabs working, i don't know if this is a dojo or dojango
misuse on my side.

I don't even know if i'm doing it well, and what's the matter with the
two collectors.

Anyone can help me on setting a tab layout with dojango?

Thank you!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJM94JMAAoJEAWOKfEESaOwa0oP/j+eb3ktdrmywKYhJgV/5TpI
RAEjBzHqluhMNVflk0oVo7gmozyIO3CxeR4NHJJbHfdWYu8Arqro4ObzWZ+YrWFT
Fn+2kQH2GLJ59tVLFFQL8nB9MUNvJ4EBvUpNhuFAcjMlaAglyaMaYJ3zgALQJ1Ex
ZnimcndCvTrynnhd+PYcXsfD6ztjlKRZKv2HBiPi41kgqIvR4/s9bWs5uTpba/7j
KQTUSM4Bk4GbofyOAWgk6YgEbN9gWa+EA0ktaZESOHZTEkZVyQJa0coVDodm5Is5
WNXH47PrWDH/dortN8jV9GYrs4bzKMolVIRyYLY6f1HwRgEDd8qpXAI7IlFZC5JU
4v50t8rm1ComXZIs9tE6e1EJPSRBWxrShmTC8bFA0U+AX4l3C9zvDvFF4ugFKNt1
OT/xIO/9Eby4XG52cQvdcBDsiDj5Rf4+pqyrLzlM7BeDHglVRb4I1kUm1K3tWJpv
Nw2l4Q1b/vdELt0qMFCACxO6nt82B9yrNdI6iJ8XP7szhRACkd5r1d4Wq+8XMtLH
c9BuNJQrZe0r9e5/gZx0yLDI8RbIV3BeVwQ5dXo2KeQYCU/hnYs7E/E/dEkjONHT
P9zk4HZ9Oif8ACZyK9iv98t/DcEZRtPRPMBM4lcPFC3UhDj3fKE7h+nByk1291LF
rITHO7Ry5Qt3miQiyqx4
=EnYO
-----END PGP SIGNATURE-----

noel

unread,
Dec 18, 2010, 10:54:33 AM12/18/10
to dojango-users
have this same problem, dont know why middleware is not working
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/

klipstein

unread,
Dec 18, 2010, 11:48:45 AM12/18/10
to dojango-users
Hi Ferran and Noel,

the DojoCollector is the middleware that cares about creating a global
collector object, where you are able to add dojo modules from several
places (views.py / forms.py / ...).

If you don't add the "dijit.layout.TabContainer" and
"dijit.layout.ContentPane" to that collector it won't add the
"dojo.require" call. Just do the following in your views.py:

from dojango.util import dojo_collector

def my_view(request):
dojo_collector.add_module("dijit.layout.ContentPane")
dojo_collector.add_module("dijit.layout.TabContainer")
...

This ensures that these modules will be picked up by the DojoCollector
middleware. But you could also define these required modules in a
script tag in your template:

<script type="text/javascript">
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.ContentPane");
</script>

Additionally you have to pass a title for each ContentPane and define
a width/height for the TabContainer:

<div dojoType="dijit.layout.TabContainer" style="width:400px;height:
100px;">
<div dojoType="dijit.layout.ContentPane" title="My first tab"
selected="true">Tab 1 Content</div>
<div dojoType="dijit.layout.ContentPane" title="My second tab">Tab 2
Content</div>
<div dojoType="dijit.layout.ContentPane" title="My third tab">Tab 3
Content</div>
</div>

You can also see a complete example in the dojango-sample project:

https://github.com/klipstein/dojango-sample/commit/8f84a29ad48a443cc049273346170539449ed426

For more info about Dojo's TabContainer you can look here:

http://www.dojotoolkit.org/reference-guide/dijit/layout/TabContainer.html
http://www.dojotoolkit.org/reference-guide/dijit/layout/TabContainer-examples.html

Regards, Tobias
Reply all
Reply to author
Forward
0 new messages