2011-05-18 42 views
0

可能重複:
How to break or continue Ext.each如何終止`Ext.each`中的函數?

正是我想達到的目標是在一個陣列來檢查字符串,...
如果權限爲真,則返回true .. 。

var Data = { 
    appPrivilege : [{ 
     module : "info", 
     priv : true 
    },{ 
     module : "about", 
     priv : false 
    }] 
} 

App = { 
    AP : function(a){ 
     Ext.each(Data.appPrivilege, function(c){ 
      if (c.module == a && c.priv==true){ 
       console.info("here"); 
       //return true; 
       return "a"; 
      } 
     }); 
     return "b"; 
    } 
} 

console.info(App.AP("info")); 

但在螢火蟲它顯示hereb。如何終止Ext.each ??

+0

對不起,我沒有找到它,而谷歌搜索 – 2011-05-18 07:58:54

回答

0

內線和jQuery只想回調返回false

if (c.module == a && c.priv==true){ 
    console.info("here"); 
    return false; 
}