[OpenAjaxMobile] Dojo's (and Ext's and jQuery's) use of associative arrays as parameters

Jon Ferraiolo jferrai at us.ibm.com
Thu Jul 17 18:04:30 PDT 2008



I am researching the Dojo build system (which came up both in the Mobile TF
and IDE WG phone calls this week). In going through some of the Dojo
materials, I found the following example within their hello_world tutorial
at (?http://dojotoolkit.org/book/dojo-book-0-9/hello-world-tutorial):

------
dojo.xhrGet({
           url: 'HelloWorldResponseGET.php',
           load: helloCallback,
           error: helloError,
           content: {name: dojo.byId('name').value }
        });
------

Two things to observe: (a) the single-object associative-array approach,
(b) two callbacks (success and error).

There are other parameters to xhrGet, including timeout controls, as shown
at (http://api.dojotoolkit.org/jsdoc/dojo/HEAD/dojo.xhrGet). There are a
number of APIs in Dojo that use the single-object associative-array
approach.

I also skimmed through some of the APIs for another popular library, Ext
JS, and they also used the single-object associative-array approach in a
number of their APIs.

jQuery doesn't seem to use single-object associative-arrays as parameters
as often as Dojo and Ext JS, but it does appear in some of jQuery's APIs.

Here is what I conclude:
* JavaScript developers are able to deal with APIs that use associative
arrays to pass name-value pairs
* But none of the major toolkits goes overboard using this technique

Jon



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openajax.org/pipermail/mobile/attachments/20080717/acd7e7d5/attachment.html 


More information about the mobile mailing list