0
如果我有formatSelection
的标记,其中包含图像并且select2-selecting
事件中有window.location.href
事件,则图像将被破坏。如果我删除window.location.href
,则图像可以工作,并且可以在加载新页面之前看到。格式图像在将用户发送到选择事件的新页面时,选择标记被打破
$('.select2#topbarSearch').on("select2-selecting", function(e) {
window.location.href = 'www.example.com';
});
function selectionFormat(data) {
var markup = "<table class='search-result'><tr>";
if (data.image !== undefined) {
markup += "<td class='data-image'><img style='height: 25px;' src='" + data.image + "'/></td>";
}
markup += "<td class='data-info-selected'><div class='data-title'>" + data.title + "</div>";
markup += "</td></tr></table>";
return markup;
}