On 8-Jan-07, at 6:57 PM, Alberto Valverde wrote:



On Jan 9, 2007, at 12:45 AM, Igor Foox wrote:


Hi all,

I'm trying to use CalendarDatePicker in my app, and am getting strange errors. It seems that the JS files that were supposed to be included by the JSLink are not getting included. When I open the page up in firefox I get the following JS error:
'Calendar is not defined'
on the line:
Calendar.setup(

which comes from the template of the widget.

My code looks like this, at the top of my controllers.py I have:
class AssignmentEdit(widgets.WidgetsList):

    # FIXME: need to validate that it doesn't already exist
    name = widgets.TextField(validator = validators.NotEmpty())
for_widget = widgets.CalendarDateTimePicker (name="my_date_picker")
    released = widgets.CheckBox()
    solution = widgets.FileField()
    class_name = widgets.TextField(validator = validators.NotEmpty())
assignment_type = widgets.SingleSelectField (name="edit_type_selecter", options=[
                                                (1, "Java"),
(2, "Python")], default=1)


assignment_edit_widget = widgets.TableForm(fields=AssignmentEdit(),
submit_text = "Save assignment")


In the controller method I have:
    def assignment(self, assignment_id):
        edit_form = {'form': assignment_edit_widget,
                        'action': '/blah',
                        'values': Assignment.get(assignment_id)}
return dict(assignment= Assignment.get(assignment_id), edit_widget=edit_form)


In my template I have:

<div id="assignment_edit" py:if="'instructors' in tg.identity.groups"><h3>Edit Assignment</h3> ${edit_widget['form'](values=edit_widget['values'], action=edit_widget['action'])}
                </div>


This seems to me the correct way to use the widget, but as I said it doesn't work. I'm using 1.0, and the widget works when I look at it in the widget browser. Am I doing something wrong?

Try passing the form in the first level of the output dict, not inside 'edit_widget'.

Yes that worked, I was actually just about to reply with that when I got your message. :)

Is this the "expected" thing to happen, or should I file a bug?

It would be useful to be able to pass widgets in dicts in the case where you're passing several widgets back to the template.

Igor

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to