Re: Mootools to Dojo/Mojo conversion

16 views
Skip to first unread message

Kyle Campbell

unread,
Sep 28, 2010, 2:34:18 PM9/28/10
to blast...@googlegroups.com, Cox-UI-Manager
dojo.forEach(options, function(value,key,arr){

});

http://api.dojotoolkit.org/jsdoc/1.2/dojo.forEach

On 9/28/2010 11:31 AM, Cox-UI-Manager wrote:
> I have some Omniture mojo code and am trying to convert a piece of
> mootools script into either dojo or mojo (if it exists). I am having
> trouble finding the equivalent of the Mootools $each function. Does
> anyone know?
>
> Sample code:
>
> $each(options, function(value, index) {
> switch(index) {
> /* English => Omniture mapping */
> case 'localePagename': // localName : pageName
> ...
> break;
> case 'pageName':
> ...
> break;
> }
> }
>
> Thanks!

Kyle Campbell

unread,
Sep 28, 2010, 2:46:21 PM9/28/10
to blast...@googlegroups.com, Robert...@cox.com


They should be the same. I did make one typo from your example:
dojo.forEach(options, function(value,index,arr){
	console.log(value,index,arr);
});
Please send back what you get in your console using this.

I'm pretty sure dojo handles objects using forEach, if not you might have to tackle this old school:

for(var i=0; i<options.length; i++){
    console.log(options[i]);
}

From my experience though these are basically different syntax for the same logic.

On 9/28/2010 11:40 AM, Robert...@cox.com wrote:
Tried that but that dojo code is the equivalent of doing mootools options.each(value,index) which is different.

-----Original Message-----
From: blast...@googlegroups.com [mailto:blast...@googlegroups.com] On Behalf Of Kyle Campbell
Sent: Tuesday, September 28, 2010 2:34 PM
To: blast...@googlegroups.com

Cox-UI-Manager

unread,
Sep 28, 2010, 2:31:40 PM9/28/10
to Blast Mojo

Robert...@cox.com

unread,
Sep 28, 2010, 2:40:50 PM9/28/10
to blast...@googlegroups.com
Tried that but that dojo code is the equivalent of doing mootools options.each(value,index) which is different.

-----Original Message-----
From: blast...@googlegroups.com [mailto:blast...@googlegroups.com] On Behalf Of Kyle Campbell
Sent: Tuesday, September 28, 2010 2:34 PM
To: blast...@googlegroups.com
Cc: Sekman, Robert (CCI-Atlanta)
Subject: Re: Mootools to Dojo/Mojo conversion

Robert...@cox.com

unread,
Sep 28, 2010, 3:01:42 PM9/28/10
to blast...@googlegroups.com
This returns nothing in Console:
dojo.forEach(options, function(value,index,arr){
 console.log(value,index,arr);
});
 
This returns data in the Console:
$each(options, function(value, index) {
 console.log(value,index);
});
 
Doesn't appear to be the same thing.


From: Kyle Campbell [mailto:slajax.s...@gmail.com]
Sent: Tuesday, September 28, 2010 2:46 PM

Kyle Campbell

unread,
Sep 28, 2010, 3:13:21 PM9/28/10
to blast...@googlegroups.com, Robert...@cox.com

You are right: http://jsbin.com/isadu4

No idea why dojo doesn't support this as mootools jquery do.

Use native old school style for objects, as shown in example:

for(var j in options){

}
Reply all
Reply to author
Forward
0 new messages