在ID选择器中使用特殊字符(%)关闭selectmenu时出现jQuery UI语法错误

时间:2017-12-20 16:18:24

标签: javascript jquery jquery-ui

当我点击菜单外部(或明确关闭菜单)时,我有一个selectmenu抛出以下错误

Uncaught Error: Syntax error, unrecognized expression : .ui-selectmenu-menu, #My%20System_input-button
    at Function.fa.error (http://localhost:8081/jquery/jquery-2.2.4.min.js:2:12556)
    at fa.tokenize (http://localhost:8081/jquery/jquery-2.2.4.min.js:2:18609)
    at fa.compile (http://localhost:8081/jquery/jquery-2.2.4.min.js:2:21240)
    at fa.select (http://localhost:8081/jquery/jquery-2.2.4.min.js:2:21948)
    at fa (http://localhost:8081/jquery/jquery-2.2.4.min.js:2:7143)
    at Function.fa.matchesSelector (http://localhost:8081/jquery/jquery-2.2.4.min.js:2:12175)
    at n.fn.init.closest (http://localhost:8081/jquery/jquery-2.2.4.min.js:2:25517)
    at $.(anonymous function).(anonymous function).mousedown (http://localhost:8081/jquery/jquery-ui-1.11.4.js:12549:28)
    at HTMLDocument.handlerProxy (http://localhost:8081/jquery/jquery-ui-1.11.4.js:726:7)
    at HTMLDocument.dispatch (http://localhost:8081/jquery/jquery-2.2.4.min.js:3:7537)

从我的谷歌搜索来看,这可能是jquery-ui-1.11.4中以下函数中ID选择器中%的问题。我用错误跟踪

跟踪了这个功能
_documentClick: {
    mousedown: function( event ) {
        if ( !this.isOpen ) {
            return;
        }

        if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
            this.close( event );
        }
    }
},

有什么方法可以解决这个问题,还是只需要找出一个更好的ID来用于我的元素?

0 个答案:

没有答案