Thanks Christoph and NiL. For now I just created the table and form
instance in the main controller. Is that wrong? You said its in the
V, but shouldn't it be in the C? By instantiate I mean
autoField = AutoCompleteField(
id='myFieldName',
completionURL = 'fetch_states',
fetchJSON = True,
minChars = 1)
from the tutorial here
http://turbogears.org/2.1/docs/main/ToscaWidgets/Cookbook/AutoComplete.html.
Speaking of, I've been trying and trying to get this tutorial to work
but can't seem to do it. It's not giving me any errors, it's just not
working. The page displays and everything but the autocomplete is not
working. Is there some other thing I need to easy_install or
something or is there an error in the tutorial? I already took care
of the
from pylons import tmpl_context
and changed
@expose('mypackage.templates.myformtemplate')
def entry(self, **kw):
pylons.c.form = myForm
return dict(value=kw)
to
@expose('mypackage.templates.myformtemplate')
def entry(self, **kw):
tmpl_context.form = myForm
return dict(value=kw)
It seems like it should work since I'm just pretty much copying the
tutorial...did I make a mistake somewhere? Everything else I did is
identical to the tutorial. Thanks
Also, NiL, I tried using the code you posted, but it gave me errors
about 'no module ui.widgets' even though I installed abl.jquery.
On Feb 6, 1:14 pm, Christoph Zwerschke <[email protected]> wrote:
> Am 06.02.2011 21:58 schrieb Nate:
>
> > I'm new at this and am wondering the proper place to instantiate a
> > widget. Specifically, I'm trying to make an autocomplete form (http://
> > docs.turbogears.org/2.0/RoughDocs/ToscaWidgets/Cookbook/AutoComplete)
> > but in all of the tutorials I've found, I can't seem to find WHERE to
> > instantiate a widget (or at least the best/proper place to instantiate
> > a widget). Should it by in my model as a separate .py file? Do I
> > then need to create another database to deal with that object? Or
> > should I instantiate in the __init__.py in my model? Or is it
> > somewhere else?
>
> I usually create "lib" and "widgets" packages inside TG projects.
> Sometimes I also create a "widgets/templates" subpackage for the widget
> templates. The controller modules can then import from the "lib" and
> "wdigets" packages and assign the widgets to tmpl_context.
>
> In any case, don't put them into the model package, they don't belong
> there. In the MVC pattern, widgets clearly belong to "V", not "M".
>
> -- Christoph
--
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.