I ran into trouble, however, with trying to get the ajax portion
working. Everything works up until I hit "submit", at which point
it's bahaving like a normal form.
Would someone take a look at the page, and give me some pointers on
what I'm doing wrong? You'd be helping not just me, but posterity.
:-)
http://trac.turbogears.org/turbogears/wiki/RemoteForm
Thanks!
-Ken
class DemoController(identity.SecureResource):
""" Demonstrate the use of RemoteForm. """
@tg.expose(template="templates.remoteformdemo")
def index(self):
item_searchform = RemoteForm(
name="ItemSearch",
fields=SearchFormFields(),
submit_text="Search",
action=turbogears.url("/do_search"))
return dict(item_searchform=item_searchform)
You may want to remove the inheritance from identity.SecureResource, it
isn't being used and will confuse people.
Also, we are trying to move the documentation from the trac wiki to its
new home at http://docs.turbogears.org/ That site is being authored
with reStructuredText though, so what you have now will eventually need
to be converted. I'll make a page on the documentation site with a link
until someone has a chance to bring it over.
Lastly, awesome work so far and beautiful timing. I was just starting
to look into this for something.
-Adam
Adam, thanks for the response(s). Unfortunately, I'm getting the same
behavior whether I set the action at create time within the controller,
or during the template's display call. Any other ideas? I'm stuck.
Thanks also for the suggestion on removing the secureresource
reference. Unfortunately, with the trac wiki lockdown I can't make
changes to the page I created, so won't be able to fix that. (or for
that matter, the other problem either, assuming I ever get it figured
out.)
Maybe I shouldn't have created the page at all... having wrong
documentation's probably even worse than having none. So, sorry for
that.
-ken
> -Adam
>
>
> >
>
I ran into trouble, however, with trying to get the ajax portion
working. Everything works up until I hit "submit", at which point
it's bahaving like a normal form.
This got me back on track. There was indeed an error executing the
javascript... I just didn't notice it because it disapeared when the
refresh happened. The error I was getting was 'getElement("loading")
has no properties'. Once I put a sleep into the do_search method, it
popped up like a sore thumb.
So I flipped the divs to use ids instead of names, and it worked like
a champ. (ie, in the template, <div name="loading"> became <div
id="loading"> )
Kevin, thanks for pointing me in the right direction!
-Ken
PS: Someone migrated the documentation that I had attempted over to
the new doc site (thanks to them, too), so I fixed the bug there as
well. Would someone be willing to delete the broken version of the
doc at the trac wiki?