admin管理员组文章数量:1290400
I'm using the Twitter Typeahead. There is an issue when I have preloaded data in my text box and on the blur
event, the text box is clearing. This is a known issue within the type ahead and it says it was fixed. But I can't quite figure out how to implement the fix.
I have my typeahead initialize like this in the (document).ready
function
$('#myTextbox').typeahead({
name: 'Typeahead',
valueKey: "Value",
remote: '/ServiceHandlers/myHandler.ashx?Method=Typeahead&Query=%QUERY',
template: ['<p>{{Value}}</p>'],
engine: Hogan
});
The issue says to add something like
$('.typeahead').typeahead('setQuery', '');
But I can't quite see where this would go. Any suggestions on how to fix this issue?
I'm using the Twitter Typeahead. There is an issue when I have preloaded data in my text box and on the blur
event, the text box is clearing. This is a known issue within the type ahead and it says it was fixed. But I can't quite figure out how to implement the fix.
I have my typeahead initialize like this in the (document).ready
function
$('#myTextbox').typeahead({
name: 'Typeahead',
valueKey: "Value",
remote: '/ServiceHandlers/myHandler.ashx?Method=Typeahead&Query=%QUERY',
template: ['<p>{{Value}}</p>'],
engine: Hogan
});
The issue says to add something like
$('.typeahead').typeahead('setQuery', '');
But I can't quite see where this would go. Any suggestions on how to fix this issue?
Share Improve this question asked Jun 7, 2013 at 1:16 Barry TormeyBarry Tormey 3,1465 gold badges37 silver badges56 bronze badges 2-
Have you tried putting
$('#myTextbox').typeahead('setQuery', '');
after the code that initializes the typeahead? – clav Commented Jun 7, 2013 at 1:22 - Yes. This just seems to set the query, and therefore the text in the textbox to blank on blur. Causing the same problem as it has now. – Barry Tormey Commented Jun 7, 2013 at 4:03
2 Answers
Reset to default 9Figured it out!
Just had to set
$('#myTextbox').typeahead('setQuery', $(#myTextbox).val());
in the typeahead.open
function.
Here was my solution:
var typeaheadElement = $('element-selector');
typeaheadElement.bind('typeahead:open', function() {
typeaheadElement.typeahead('val', typeaheadElement.val());
});
本文标签: javascriptTypeaheadjs on Blur EventStack Overflow
版权声明:本文标题:javascript - Typeahead.js on Blur Event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741409801a2377162.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论