"jfagnani" <[EMAIL PROTECTED]> writes:

I'm loading some data with loadJSONDoc() and need to pass some
additional information to the callback function besides just the JSON.

My specific situation is that I have a form with several line items.
When the user enters a code into one field on the line item, I need to
lookup some data and fill out a few other fields. So what I need to
pass to the callback is either the line item number, or preferably an
object I have that encapsulates information about the line item.

Any ideas?

If I understood you correctly you want something like:

   var d = loadJSONDoc('/addresses/states/json_states/?country=' + 
escape(country) +
                       '&tg_random='+timestamp());
   d.addCallback(create_select_state, destination, destination_id);
   d.addErrback(metadataFetchFailed);


This will call the create_select_state function passing destination,
destination_id and the return from the call to the JSON method (in that order)
as parameters.

See that you have to add the error handler separately since addCalbacks
doesn't accept extra parameters.

I think it'd be nice if the Deffered callbacks worked like connect()
does, in that it could take an object and function.

;-)  I believe, then, that you'll be happy with the above.

--
Jorge Godoy      <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" 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/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to