2015-09-16 29 views
0

我有一個Selecized select,雖然我可以在調試器中看到選擇的控件包含所需的選項,但它沒有顯示帶選項的彈出式窗口。當我點擊下拉按鈕時,箭頭會像顯示列表時那樣向上指向,但這是它的全部功能,並且不顯示包含選項列表的彈出窗口。此外,此下拉菜單位於引導模式對話框內。以下代碼片段顯示了Selectize下拉菜單的初始化和選擇。第一部分初始化控制。Selectize.js無法下拉到彈出式對話框

enter image description here

以下負載的選項數組:

enter image description here

這就是selectization發生。首先,我們調用初始化方法加載選項,然後使用生成的實例化控制創建selectized控制:

enter image description here

順便說一句,我有完全相同的代碼在另一頁上的工作,但我只是不明白爲什麼它不會在這個頁面中工作。這兩種情況下的代碼都是相同的。

代碼的文本格式:

var sgAllSelectize = []; 

var pplicationId = null; 

function bindAllSGContainer(appId, option) { 
    /* ok, so we loaded the SG select element, time to selectize it */ 
    var handler; 
    var pageType = $("#hdnPageType").val(); 
    if (pageType == 'clone') { 
     handler = onChangeSGidForAllServer; 
    } 
    if (pageType == 'migration') { 
     handler = onChangeMigrationSGidForAllServer; 
    } 
    if (pageType == 'failover') { 
     handler = onChangeFailoverSGidForAllServer; 
    } 

    var element = "#allServerSGselect_" + appId; 
    applicationId = appId; 

    var $vs = $(element).selectize({ 
     create: true, 
     sortField: 'text', 
     placeHolder: 'Example: sg-00000000', 
     persist: false, 
     options: option, 
     createOnBlur: true, 
     allowEmptyOption: false, 
     closeAfterSelect: true, 
     onChange: function (input) { 
      var aid = appId; 
      var sgValid = input.search(/^sg-[a-zA-Z0-9]{8}$/i); 
      var sg_selection = $("option", element); 
      var sg_selection_stripped = sg_selection.val().slice(0, 11); 
      if (sgValid == 0) { 
       sg_selection.val(sg_selection_stripped); 
       handler(input, aid); 
      } else { 
       console.log("sg " + input + " is not valid"); 
       this.removeOption(input, "silent"); 
       this.setValue(""); 
       /* sending an empty sg id will disable the sg elements */ 
       handler("", aid); 
      } 
     } 
    }); 
    sgAllSelectize[appId] = $vs; 
} 


var allOptsArray = []; 

//load up the options into an object array 
for (var h = 0; h < str1.length; h++) { 
    optAllSgObject = new Object(); 
    optAllSgObject.text = str1[h]; 
    optAllSgObject.value = str1[h]; 
    allOptsArray.push(optAllSgObject); 
} 
    bindAllSGContainer(appId, allOptsArray); 
    var o = sgAllSelectize[appId]; 
    selectizeAll = o[0].selectize; 
+1

請不要發佈代碼的形象,但代碼本身 –

+0

對不起,我只是不知道如何得到它的格式正確。我對此很感興趣。同樣在第一行應該是「..with ..」而不是「......哪個..」 –

+0

您可以發佈您的代碼並使用相應的降價按鈕來設置您的代碼的格式請參閱:http://stackoverflow.com/editing-help –

回答

0

答案就藏在一個評論。

周圍的單元格或表具有溢出隱藏。確保這被設置爲溢出:可見。