【发布时间】:2013-11-25 07:37:19
【问题描述】:
我正在使用 select2。内置事件不支持所选项目上的悬停事件,因此我试图在鼠标悬停在项目上时触发悬停事件(多选)。
function tagFormat(state) {
return '<span class="tagElement">' + state.text + '</span>';
}
$('.tagElement').hover(function(event){
alert('something');
});
var sampleTags = ['red','white'];
$("[taggable]").select2({
formatSelection: tagFormat,
maximumInputLength: 10,
tags:sampleTags,
tokenSeparators: [",", " "]
});
Bootply at http://bootply.com/96527 ,您可以看到在 select2 外部,悬停事件确实会触发,但在 select2 内部却不会。里面的机制是什么?
【问题讨论】: