Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'options' of undefined #3

Open
yinyang opened this issue May 5, 2017 · 2 comments
Open

Uncaught TypeError: Cannot read property 'options' of undefined #3

yinyang opened this issue May 5, 2017 · 2 comments

Comments

@yinyang
Copy link

yinyang commented May 5, 2017

我有多个tabs 在关闭某个使用了 combbox的组件的页面时触发该错误

Uncaught TypeError: Cannot read property 'options' of undefined
    at _9f5 (jquery.easyui.min.js:13220)
    at HTMLInputElement.<anonymous> (jquery.easyui.min.js:13477)
    at Function.each (jquery.js:365)
    at jQuery.fn.init.each (jquery.js:137)
    at destroy (jquery.easyui.min.js:13476)
    at jQuery.fn.init.$.fn.combo (jquery.easyui.min.js:13441)
    at jQuery.fn.init.$.fn.combo (jquery.easyui.extensions.js:587)
    at HTMLInputElement.<anonymous> (jquery.easyui.min.js:3091)
    at Function.each (jquery.js:365)
    at jQuery.fn.init.each (jquery.js:137)

可以确定是 combo这个扩展导致的 因为我页面如果不用这个组件 可以正常关闭 一旦用上 在关闭tab时 就报错了

作者可有好的解决办法 🤕

@yinyang
Copy link
Author

yinyang commented May 5, 2017

这个可能是我用的不恰当 我多个页面都有相同的组件 我用ajax加载的 使用了相同的选择器
现在添加了 上下文逻辑 就好了:

    var context = '<?= $context ?>';   // 早期没有上下文限制
        var $input = null;
        if (context != '') {
            $input = $(':input[name="rapid_date_range"]', context);
        } else {
            $input = $(':input[name="rapid_date_range"]');  
        }
        $input
        /* .combobox('destroy') */
            .combobox({
            ...

想共用一段代码 如果不加上下文选择器限制 估计一个组件被反复实例化(我也想过先 安全的销毁以前的 失败了 所以还是老老实实 添加个上下文选择器限制下)

感谢你了 ✌️

@loafer
Copy link
Owner

loafer commented May 8, 2017

客气,问题是你自己解决的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants