我已下载Demos.nsf并尝试从http://www.bootstrap4xpages.com/bs4xp/demos.nsf/select2.xsp
学习select2一切运行良好但我发现问题当返回“找不到匹配项”时,select2没有触发XPAGES服务器端事件
这里是如何产生这个问题的:
如何解决这个问题?
这是我的代码:
<xp:inputHidden id="inputHidden1" value="#{document1.coba}"/>
<xp:scriptBlock id="scriptBlock4">
<xp:this.value><![CDATA[
x$( "#{id:inputHidden1}" ).select2({
placeholder: "Find someone",
minimumInputLength: 2,
quietMillis: 300,
width: '300px',
allowClear : true,
ajax: {
url: "namesDataStore.xsp",
dataType: 'json',
data: function (term, page) {
return {
q: term, // search term
page_limit: 10
};
},
results: function (data, page) { // parse the results into the format expected by Select2.
return data;
}
},
initSelection: function(element, callback) {
//sets a default value (if a value was selected previously)
var id = $(element).val();
//if a value was selected: perform an Ajax call to retrieve the text label
if (id !== "") {
$.ajax(
"namesDataStore.xsp", {
data: {
id: id
},
dataType: "json"
}).done(function(data) { callback(data); });
}
}
});
]]></xp:this.value>
</xp:scriptBlock>
<xp:text escape="true" id="computedField1"
value="#{document1.coba}">
</xp:text>
<xp:button value="Refresh"
id="button2" styleClass="btn btn-success">
<i class="glyphicon glyphicon-ok " />
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="computedField1">
</xp:eventHandler>
</xp:button>