Widget issues

9 views
Skip to first unread message

David Bernick

unread,
Dec 8, 2009, 1:40:43 PM12/8/09
to dojang...@googlegroups.com
Hello again,

I am using DateInputAnim (or DateInput) because I want one of those
cool popup calendars (yes, they're cool).

When I use the code below in my form, I get a text box, but when I
click on it, nothing happens. While this is functional, I would love
to see the calendar widget.

Below is from my forms.py and then the HTML it generates. Am I missing
something?


-----
birthdate = fields.DateField(
label="Birthdate of elder patient",
help_text="Month Day Year",
required=True,
widget=widgets.DateInputAnim(attrs={
'invalidMessage': 'The date is invalid!',
}))
---------
<input name="birthdate" invalidmessage="The date is invalid!"
required="true" promptmessage="Month Day Year" id="id_birthdate"
dojotype="dojox.form.DateTextBox" type="text">

klipstein

unread,
Dec 8, 2009, 3:36:07 PM12/8/09
to dojango-users
Hey David,

I assume that you are just missing the following middleware in
settings.py:

MIDDLEWARE_CLASSES = (
'dojango.middleware.DojoCollector',
# (not named DojoAutoRequireMiddleware anymore!)
// ...
)

For the DateInputAnim you also have to output the media-files of the
form in your template, because a separate stylesheet is required for
that:

<head>
{{ form.media }}
...
</head>
<body>
...
{{ form }}
</body>

The output of the input looks right for me. Seems like there is a JS
error somewhere and i assume it is because the dojo.require
("dojox.form.DateTextBox"), which is generated by the middleware, is
missing. If you should have any other client (JS) related problem I
suggest first looking at your firebug console.

Regards, Tobias

David Bernick

unread,
Dec 8, 2009, 3:45:17 PM12/8/09
to dojang...@googlegroups.com
> MIDDLEWARE_CLASSES = (
>    'dojango.middleware.DojoCollector',
>    # (not named DojoAutoRequireMiddleware anymore!)
>    // ...
> )

I definitely have that.


I should say that the fields that are not working properly are ones
that appear after an Ajax submission:
1. Pick from a dojango ChoiceField (works just fine).
2. onChange, submit to Django via Ajax (works just fine).
3. When the response comes back, it puts new fields into the document.
In other words, one form spawns another (like a wizard). The new
fields appear to just be regular fields, although I specify for them
to be specific dojango fields.

Everything works fine when it's not part of an Ajax response.

I suspect THAT'S the problem. Any tips there?

klipstein

unread,
Dec 8, 2009, 3:54:45 PM12/8/09
to dojango-users
That is easy. You just have to reparse the returned HTML with:

dojo.parser.parse(dojo.byId("filledDomNode"));

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