Hi,

you could use 
Object.filter: http://mootools.net/docs/core/Types/Object#Object:Object-filter

Take a look at this fiddle: http://jsfiddle.net/unlooped/K7WfE/7/

Best,
Steffen

On Thursday, February 21, 2013 11:41:36 AM UTC+1, Hamburger wrote:
>
> Hello,
> I would like to find a value in an data-object. (Has the given ID a true 
> ajax-flag?)
> I made this to find the value:
> http://jsfiddle.net/K7WfE/6/
>
> //the data object
> var obj = {
> 'apple' : { 'id': '123', 'valid' : 0 , 'ajax' : 1 } ,
> 'bwe' :   { 'id': '456', 'valid' : 1 , 'ajax' : 1 } ,
> 'na' :    { 'id': '789', 'valid' : 0 , 'ajax' : 0 } ,
> 'ana' :   { 'id': '345', 'valid' : 1 , 'ajax' : 1 } ,    
> };
>
> var ajax = [];  //to store the result
> for( var name in obj ) {
>     if(obj[name].valid ==true) ajax.push(obj[name].id );    
> }
> console.log(ajax);
>
> var search = '456'; //given ID
>
> var info = ajax.contains(search); //gives the status back.
>
> console.log("Info: ",info);
>
> I think this is not very elegant.
> Is there a better mootools way?
> thanks for any suggestion in advance
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mootools-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to