如何将 kartik typeahead 置于文本输入之上
How to place kartik typeahead above text input
如何将预输入结果置于文本输入上方?对我来说最好的办法是为这个小部件添加一个选项或者一些 css 规则 ?
此刻我终于在 typeahead 小部件的 render
事件中使用了 jQuery
解决方案,方法是在每次渲染后修改 css margin-top
。这是代码:
echo Typeahead::widget([
//(...)
'pluginEvents' => [
'typeahead:render' => 'function(event,ui) {
var ttMenu = $("#search-main .tt-menu").first();
var ttMenuHeight;
if($(ttMenu).hasClass("tt-open")) {
ttMenuHeight = -$(ttMenu).height();
$(ttMenu).css("margin-top", ttMenuHeight - 70);
}
}',
],
//(...)
]);
'#search-main .tt-menu'
是我的输入选择器,这个“70
”是这个输入的高度所以一定要用你自己的替换它。
希望对您有所帮助。
如何将预输入结果置于文本输入上方?对我来说最好的办法是为这个小部件添加一个选项或者一些 css 规则 ?
此刻我终于在 typeahead 小部件的 render
事件中使用了 jQuery
解决方案,方法是在每次渲染后修改 css margin-top
。这是代码:
echo Typeahead::widget([
//(...)
'pluginEvents' => [
'typeahead:render' => 'function(event,ui) {
var ttMenu = $("#search-main .tt-menu").first();
var ttMenuHeight;
if($(ttMenu).hasClass("tt-open")) {
ttMenuHeight = -$(ttMenu).height();
$(ttMenu).css("margin-top", ttMenuHeight - 70);
}
}',
],
//(...)
]);
'#search-main .tt-menu'
是我的输入选择器,这个“70
”是这个输入的高度所以一定要用你自己的替换它。
希望对您有所帮助。