Hello,
I am going to jump on this thread since I have some AutoComplete
questions and will probably have more. Its too bad i didn't see this
before it was a struggle to get the hidden field to work. Has anyone
been able to set the attributes of the textfield and hiddenfield? If
I want to do some ajax when the user does select something from the
autocomplete what is the best method without breaking the widget? I
was thinking of adding an onChange method to the hidden field so that
when a name is selected from the my list and it stores the id then the
onchange js function will be called and I can go to the server and get
the information for that name using Javascript.
Right now I use this which does nothing(no errors, just nothing):
attrs = {}
attrs['text'] = dict(size=150)
attrs['hidden'] = dict(onchange="selectPlant()")
form = TableForm(
fields=[
AutoCompleteField(name='plantName',
search_controller='getPlants', search_param='rawSearchWords',
result_name='results', label="Plant:",
attrs=attrs),...
Maybe my dictionary is setup wrong I can't really see why this doesn't work.
Thanks,
-Ian
On 10/5/06, percious <[EMAIL PROTECTED]> wrote:
>
> found the answer. The AutoCompleteField automatically comes with a
> "hidden" value. When you return your search results, return a tuple
> like: (view, hidden):
> @expose(format="json")
> def search(self, searchString):
> vars = self._generateVariables(self.iceProjectID)
> varList = []
> searchString = searchString.lower()
> items = []
> for var in vars.values():
> if searchString in (var.tag+var.description).lower():
> items.append(("%s - %s"%(var.tag,var.description),
> var.id))
> return dict(items=items)
>
> Then you can get your results something like the following:
> @expose()
> def addParameter(self, areaID, parameters=None):
> if parameters!=None:
> parameter = parameters['hidden']
> variable = Parameter.get(int(parameter))
> return dict(parameter=variable)
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---