SumoSelect响应式模式出错

129 阅读1分钟

SumoSelect是用来渲染单选/多选下拉框组件的Jquery插件,支持移动端。

一开始我的初始化配置如下:

    $(".custom-selectpicker").SumoSelect({
        placeholder: "请选择...",
        captionFormat: "已选择{0}项",
        captionFormatAllSelected: "全部",
        clearAll: true,
        selectAll: true,
        locale: ['OK', 'Cancel', '全选','取消全选'],
    });

我的业务逻辑是一开始初始化之后,要调用.selectAll,默认全选。 在桌面端没问题,但是当我使用响应式模式,并把分辨率调到相对较小的范围,或者是选择ipad air之类的设备,就会出现以下错误:

Cannot read properties of undefined (reading 'hasClass')
        at jquery.sumoselect.js:800

同时,多选下拉框无法打开。 最后参考:github.com/HemantNegi/…

解决方法:

    $(".custom-selectpicker").SumoSelect({
        ...,
        forceCustomRendering: true, 
    });