On 3/19/07, iain duncan <[EMAIL PROTECTED]> wrote:
> Ok, by grepping the eggs I figured out I could include ajax.js to get
> things going. But, usually when I figure it out myself, I come up with
> some roundabout rube goldberg solution. ;)

You shouldn't have to include ajax.js, you should just pass the
RemoteFormRequest in the dict from your controller, or put it in
tg.include_widgets in your app.cfg. (or not use that widget, see
below.)

> I have figured out how to get my js function to fire on response, and
> how to get the remote form updating a dom element. But is there a
> straightforward way to get the remote form to send its response directly
> to a js function the way one can with a mochikit deferred? Otherwise I
> suppose I will have the js remote callback interrogate a hidden element,
> but that seems a bit convoluted.

No the remoteForm just does the "fill in a dom element with what got
returned" thing. I ended up abandoning it and writing my own widget
with javascript, that looked roughly like:

function button_pushed (action, id) {  // called from onclick attribute

  function callback(xmlhttp) {
    text = xmlhttp.responseText  // whatever your controller returned
  }

  function ajax_error(err) {
    if (err.number == 403) {
      window.location = "/users/login"
    else
        alert("AJAX error: " + err.number)
  }

  d = doSimpleXMLHttpRequest(action, {id:id});
  d.addCallbacks(callback, ajax_error);
}

I also like the FireBug Firefox extension for debugging XHRs.

HTH -- Regards -- Andy

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to