开发者

jquery autosuggest ui conditional return statement

I am using jquery autosuggest ui. and it works fine. However, is that possible to have conditional return statement. If I do that my jquery blows up.

response ($.map( data.data, function(item){
    return {
      开发者_如何学运维  if (item.secT = '') {
            label: item.bodydata+" ("+item.desc+") ",
            value: item.bodydata+" ("+item.stringid+") ",
        }else {
            label: item.bodydata+" ("+item.desc+") " +" ("+item.sec+") ",
            value: item.bodydata+" ("+item.stringid+") ",
        };
    }


Your brackets are all over the place. Change it to this:

response ($.map( data.data, function(item){
    return
        item.secT == '' ? {
            label: item.bodydata+" ("+item.desc+") ",
            value: item.bodydata+" ("+item.stringid+") "
        } : {
            label: item.bodydata+" ("+item.desc+") " +" ("+item.sec+") ",
            value: item.bodydata+" ("+item.stringid+") "
        }
}));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜