Dianne Marsh schrieb:
> I'm hoping that this is something really easy, and that I'm just not
> getting how to do it.
>
> I populate a left side menubar with the contents of a dictionary
> (Option 1, Option 2, Option 3). The main part of the window is a form,
> with editable fields. Form is saved with a TurboGears function
> "saveBlahBlahBlah". This function is expose with @expose() and works
> fine when called from the submit button.
>
> If the user navigates away to a different page, FOR THIS APPLICATION,
> the contents of the form must be saved (customer requirement). I have
> figured out how to get MochiKit to help me with this, by invoking a
> submit event. But, of course, then I lose my navigation event. An
> aside, is this even the right way to do this?
>
> My original hope was that I could invoke the TurboGears function via
> the java script directly, but I can't see how to do that. Is there
> some analog to tg.url for this purpose?
>
> Similarly, if I use buttons in a bottom menu (as the customer has
> spec'd), then I need to call a javascript function as well, rather than
> using href? So how I can get at the TurboGears functions from there?
>
> Am I making this way too difficult?
Maybe I'm missing something here - but to me it looks as if all you need
to do is to have some hidden field in that form of yours. This field
will get populated with the link target, and then the form is submitted.
Then use redirection to display the target url.
So each link gets a onclick-action that will look like this:
function link_click() {
var url = getNodeAttribute(this, "href");
var f = currentDocument().forms['my_form_name'];
f.elements['redirect_target'].value = url;
f.submit();
}
You should be able to use the connect-call together with some simple
document traversing to set this eventhandler on all link-like elements.
It might then require a small rewrite with a passed event and the target
of that event, see the mochikit docs.
The unloading-stuff is tricky AFAIK - won't work too reliable. After
all, who prevents me from killing the process?
Another option I think could be of course that you immediatly submit
whatever values the user enters in the form. It would allow for the rest
of the page being undisturbed.
Diez
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---