开发者

jquery autosuggest ui conditional return statement

开发者 https://www.devze.com 2023-03-31 05:31 出处:网络
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.

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

精彩评论

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