2015-10-19 30 views
3

I'mn使用selectize加載使用一個ASP.Net web服務動態搜索結果,並與沒有問題。然而,爲了顯示結果的下拉我不得不失去和恢復焦點從selectize控制(這將刪除文本),或刪除的內容我已經輸入。顯示動態搜索結果的下拉

如何顯示結果下拉當我輸入?這是我使用

$('#input-tags3').selectize(
{ 
valueField : 'id', 
labelField : 'name', 
searchfield : 'name', 
plugins : ['remove_button'], 
options : [], 
delimiter : ',', 
highlight : true, 
persist : true, 
hideselected : true, 
create : false, 
load : function (query, callback) 
{ 
    if (!query.length || query.length < 3) 
     return callback(); 
    $.ajax(
    { 
     url : '../data/WebService1.asmx/GetLookup', 
     data : "pSearchType=CAC&pQuery=" + query, 
     type : 'GET', 
     error : function() 
     { 
      callback(); 
     }, 
     success : function (res) 
     { 
      callback(res); 
     } 
    } 
    ); 
} 
score : function (search) 
{ 
    var score = this.getScoreFunction(search); 
    return function (item) 
    { 
     return score(item) * (1 + Math.min(item.watchers/100, 1)); 
    }; 
}, 
render : 
{ 
    item : function (item, escape) 
    { 

     return '<div>' 
     + '<b>' + item.id + '</b><p>' + item.name + '</p></div>' 

    }, 
    option : function (item, escape) 
    { 

     return '<div>' 
     + '<b>' + item.id + '</b><p>' + item.name + '</p></div>' 

    } 
} 
}); 

而且,上面的代碼附加任何動態結果向下拉的代碼,並沒有按預期清除它。

+0

注:得分函數從文檔複製的selectize.js上從GitHub獲取遠程的數據;它不僅與當前的問題無關,而且還有問題,除非遠程數據源使用可用於計分的「watchers」屬性返回數據。我從我自己的代碼中刪除了這個函數,沒有任何效果。 – Adam

回答