• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

jQuery的 – 如何设置semanic UI下拉值

jquery 来源:CMB 10次浏览

我想从选项jQuery的 – 如何设置semanic UI下拉值

statuses = [ 
    { value: 'all', name: 'All' }, 
    { value: true, name: 'Received' }, 
    { value: false , name: 'Not Yet' } 
]; 

// my jquery doesn't work 
if (params['invoiceStatus'] && params['invoiceStatus'] !== '') { 
    this.args.invoiceStatus = params['invoiceStatus']; 
    $('#invoiceStatus').dropdown(
     'set selected', params['invoiceStatus']); 
} else { 
    $('#invoiceStatus').dropdown('all'); 
} 

阵列设置一个值下拉我加入这个jQuery:

if (params['invoiceStatus'] && params['invoiceStatus'] !== '') 
{ 
    this.args.invoiceStatus = params['invoiceStatus']; 
    $('#invoiceStatus').dropdown('set selected', params['invoiceStatus']); 
} 
else { 
    $('#invoiceStatus').dropdown('all'); 
} 

但不工作

===========解决方案如下:

https://semantic-ui.com/modules/dropdown.html#/usage

根据语意UI的文档,如果你想有创建dropd拥有与所选值:

var selectedHelper = function (params, name) { 
    if (params['invoiceStatus'] === name) return true; 
    return false; 
} 

var statuses = [ 
    { 
     value: 'all', 
     name: 'All', 
     selected: selectedHelper(params, 'All'), 
    }, 
    { 
     value: true, 
     name: 'Received' 
     selected: selectedHelper(params, 'Received'), 
    }, 
    { 
     value: false, 
     name: 'Not Yet' 
     selected: selectedHelper(params, 'Not Yet'), 
    } 
]; 

$('#invoiceStatus').dropdown({ values: statuses }); 

版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)