【发布时间】:2022-02-08 14:07:14
【问题描述】:
我正在使用jQuery UI 工具提示和Select2。我的代码如下。
let selectEle = cellEle.children("select").select2({
//more code here
});
selectEle.on("select2:opening", function (e) {
$(document).on('hover', '.select2-results__option', function () {
$(this).tooltip({
position: {
my: "center bottom-20",
at: "center top",
using: function( position, feedback ) {
$(this).css(position);
var txt = $(this).text();
$(this).html(txt);
$( "<div>" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
}
});
});
});
selectEle.on("select2:closing", function (e) {
$('.select2-results__option').tooltip('close');
});
但我收到的是Uncaught Error: cannot call methods on tooltip prior to initialization; attempted to call method 'close'。
【问题讨论】:
标签: jquery jquery-select2 jquery-ui-tooltip