Reputation: 845
I want an autocomplete_extender textbox. I have written code like below:
//For autocomplete extender
$(function () {
$('.tags').autocomplete({
source: function (request, response) {
$.ajax({
url: "GoalSheet2.aspx/GetAllMentoredMembers",
data: "{ 'prefixText': '" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response(data.d);
self.LoadGoal();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('error occured while autocomplete');
}
});
},
minlength: 2,
});
});
But here i am using jquery autocomplete. I want to know is there any way to do it in knockout? And after selecting one value i want to get that value.
Upvotes: 0
Views: 240
Reputation: 3250
You can create custom binding and apply your autocomplete in the binding.
For more details how to implement custom binding read here http://knockoutjs.com/documentation/custom-bindings.html
You can also read my article where I described how to attach jquery datepicker through the custom binding, but it is written in Russian. Try to translate it with google or just review the code in jsfiddle, maybe it will help you http://www.delmadman.blogspot.com/2012/01/jquery-datepicker-c-knockoutjs.html
Upvotes: 1