So I guess there are a few ways of looking at this, but I really wish I
could access both the evaluated JSON header and the container in the
same function. I want to call an Ajax.Updater, passing an onComplete or
insertion function. In whichever function I use I want to be able to
access both the container passed to the Ajax.Updater, and the X-JSON
object that has already been eval'd *in the same function*. Am I wrong
that this isn't (easily?) possible?

The insertion function gets the container and the transport.responseText
and the onComplete get the xhr and the X-JSON object. Why cannot one get
both? And yes, "this" is useless in both cases.

Ok, so some say the X-JSON and onComplete is only for "status" checking
or error checking. However, it doesn't feel right to use json and then
have to eval it myself in the insertion. I wouldn't be using json except
I'm working with tables and some browsers don't like inserting cells
into table with innerHTML.. So I'm passing either an array or a hash
through JSON and then looping through it to build each cell using DOM
and in a special case, one cell spanning the entire row.

Is there a better way to do this?

function myInsertion(container,response){
    var res = json_decode(mytext);
    if(res.form){
       //single cell spanning all columns
    }else{
       //build table cells for each item in res
    }
}
<tr id="blah>...</tr>
Ajax.Updater('blah','page.php',{insertion:myInsertion});

I'm trying to stay consistent by keeping json only in headers and html
only in the content of the response. I could eval the headers myself but
then it'd get eval'd twice, which could cause some unwanted behavior..

Thanks,
Colin



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---

Reply via email to