TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nikhil Bandivan
1.5k
289
3.1k
Clearing a Typeahead if no value is selected from the dropdo
Feb 2 2018 6:39 AM
I use typeahead.js as autocomplete textbox.
when I input and select a value from the suggestions, textbox and hiddenfield sets the value correctly. But when I input a value and loose focus of textbox without selecting textbox value and hiddenfield value are missmatch.
How do I clear the value of the textbox and hiddenfield when the input value is not selected from suggestions.
$(
function
() {
$(
'#txtCustomer'
).typeahead({
hint:
true
,
highlight:
true
,
minLength: 1,
source:
function
(request, response) {
$.ajax({
url:
'/Customer.aspx/GetCustomers'
,
data:
"{ 'prefix': '"
+ request +
"'}"
,
dataType:
"json"
,
type:
"POST"
,
contentType:
"application/json; charset=utf-8"
,
success:
function
(data) {
items = []; map = {};
var
obj = JSON.parse(data.d);
$.each(obj.Data,
function
(i, value) {
map[name] = { id: value.CustomerID, name: value.FullName };
items.push(map[name]);
});
response(items);
},
error: OnError,
failure: OnError,
});
},
updater:
function
(item) {
$(
'#hfCustomerId'
).val(item.id);
return
item;
}
});
});
Reply
Answers (
0
)
bootstrap popup
Sum is coming in (-) and value is adding up