RemoteForm degradation, wiki page

0 views
Skip to first unread message

Ken Kuhlman

unread,
Sep 20, 2006, 11:16:47 PM9/20/06
to turbo...@googlegroups.com
Thinking I needed to learn how to use RemoteForm, and noticing the
trac wiki page for it was just a placeholder, I thought I'd kill two
birds with one stone & write a basic page as I learned...

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

Adam Jones

unread,
Sep 21, 2006, 11:00:07 AM9/21/06
to TurboGears
I think you need to set your action in the RemoteForm when you create
it instead of adding in the template's display() call. It should look
something like this:

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)

Adam Jones

unread,
Sep 21, 2006, 11:12:34 AM9/21/06
to TurboGears
A couple more notes that waited until I hit submit to pop into my head:

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

Ken Kuhlman

unread,
Sep 22, 2006, 2:55:15 PM9/22/06
to TurboGears

Adam Jones wrote:
> I think you need to set your action in the RemoteForm when you create
> it instead of adding in the template's display() call.

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

Jorge Vargas

unread,
Sep 22, 2006, 5:35:55 PM9/22/06
to turbo...@googlegroups.com
yea I was going to suggest the new move, but we haven't announce that.
there is a convertion script (on moinmoin) that could be used here.

> -Adam
>
>
> >
>

Kevin Horn

unread,
Sep 27, 2006, 3:21:13 PM9/27/06
to turbo...@googlegroups.com
On 9/20/06, Ken Kuhlman <ksku...@gmail.com> wrote:

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.


Ken,

When you say "behaves like a normal form", I assume that you mean it's refreshing the page unexpectedly.  Is that correct?  Or am I misunderstanding the problem?

I haven't delved too deeply into your code, but I have seen this problem with refreshing the page instead of loading data into the widget when there is some error in the javascript.  This can be either an error in javascript you have added, or perhaps the javascript for the widget isn't being found properly (I have seen both problems).

Hope this is of some use...

Kevin H

Ken Kuhlman

unread,
Oct 3, 2006, 6:45:31 PM10/3/06
to TurboGears

Kevin Horn wrote:
> I haven't delved too deeply into your code, but I have seen this problem
> with refreshing the page instead of loading data into the widget when there
> is some error in the javascript. This can be either an error in javascript
> you have added, or perhaps the javascript for the widget isn't being found
> properly (I have seen both problems).
>
> Hope this is of some use...
> Kevin H

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?

Kevin Horn

unread,
Oct 5, 2006, 11:42:48 AM10/5/06
to turbo...@googlegroups.com
No problem, I remember it almost drove me batty the first time I had this problem. :)

Kevin H.
Reply all
Reply to author
Forward
0 new messages