问题描述
plz给我一个明确的例子来对html文本框和数据执行自动完成操作,即在ajax调用的帮助下来自web-api的id和名称。
< input type =textid =txtVendorEmaildata-bind =autoComplete:availableEmails,value:EmailId,optionsText:'EmailName',optionsValue:'EmailvalueId'/>
plz give me a clear example to perform autocomplete operation to a html textbox and data i.e id and name coming from web-api with the help of ajax calls.
<input type="text" id="txtVendorEmail" data-bind="autoComplete:availableEmails,value:EmailId,optionsText:'EmailName',optionsValue:'EmailvalueId'" />
function EmailEntity(data) {
var self = this;
self.EmailName = ko.observable(data.EMailId);
self.EmailvalueId = ko.observable(data.ContactId);
}
var submissionline = function () {
var self = this;
<pre lang="cs">self.availableEmails = ko.observableArray([]);
self.EmailId = ko.observable("");</pre>
$ .ajax({
dataType: JSON,
类型:获取,
url:baseUri +'api / Submissions /?fltid = 5.5& ch = a& id = 1& recname ='+ RecName,
成功:函数(数据){
self.availableEmails.removeAll();
$.ajax({
dataType: "JSON",
Type: "Get",
url: baseUri + 'api/Submissions/?fltid=5.5&ch=a&id=1&recname=' + RecName,
success: function (data) {
self.availableEmails.removeAll();
$.each(data, function (i, obj) {
var c = new EmailEntity(data[i]);
self.availableEmails.push(c);
});
},
error: function (jqXHR, textStatus, errorThrown) {
$.jGrowl("Failed to get Details ." + errorThrown + ". " + "" + JSON.parse(jqXHR.responseText).Message + "." + "Please try again.",
{
theme: 'error'
});
}
});
之后当我运行它时显示self.emailid.autocomplete不是一个函数。
plz帮我解决这个问题!!!!!!!!!!
after this when i run it is showing self.emailid.autocomplete is not a function.
plz help me to solve this!!!!!!!!!!
推荐答案
之后运行它时显示self.emailid.autocomplete不是一个功能。
plz帮我解决这个问题!!!!!!!!!!
after this when i run it is showing self.emailid.autocomplete is not a function.
plz help me to solve this!!!!!!!!!!
这篇关于如何使用knockout js进行自动完成操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!