选择2 - 格式不匹配的链接 [英] Select2 - Link on formatNoMatches

查看:182
本文介绍了选择2 - 格式不匹配的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Select2 来增强我的< select> 输入。我使用coldfusion和sql填充< options> 。如果用户搜索中没有匹配项,我想使用 formatNoMatches 添加选项。我不想使用多重选择,因为它不工作与我的冷灌输,加简单地简单地添加一个点击事件到 formatNoMatches

I'm using Select2 to enhance my <select> input. I populate the <options> with coldfusion and sql. I want to use formatNoMatches to add the option if there are no matches in the user search. I don't want to use a multiple select because it does not work with my coldfusion, plus it would be much simpler to simply add a click event to formatNoMatches.

在select2.js中,有一些代码会阻止 formatNoMatches 发生鼠标事件。是否有一种方法来破解它,将允许鼠标事件?

Somewhere in select2.js, there is code that is stopping mouse events from occurring for formatNoMatches. Is there a way to hack it that will allow mouse events?

$(".select").select2({
    allowClear: true,
    blurOnChange: true,
    openOnEnter: false,
    formatNoMatches: function(term) {
        return "<a href='#' onclick='alert('" + term + "');'"
          + "id='newClient'>Add New Client</a>";
    }
});

我无法获取上述代码提醒任何内容。

I can't get the above code to alert anything.

推荐答案

这是select2的问题。同样有一个错误。但到现在还没有解决方案。

This is an issue with select2. There is a bug for the same. But till now no solution. Some idea is there, you can find the details below.

https://github.com/ivaynberg/select2/issues/276

这篇关于选择2 - 格式不匹配的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆