Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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'" />

XML
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(&quot;&quot;);</pre>

$.ajax({
dataType: "JSON",
Type: "Get",
url: baseUri + 'api/Submissions/?fltid=5.5&ch=a&id=1&recname=' + RecName,
success: function (data) {
self.availableEmails.removeAll();
PHP
$.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'
                                   });
            }
        });


after this when i run it is showing self.emailid.autocomplete is not a function.
plz help me to solve this!!!!!!!!!!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900