新的项目开发中使用了select2插件,一时兴起记录一下遇到的小问题:
**
-
默认中问题
平时用jQuery: ( " … … " ) . v a l ( x x x ) ; 默 认 选 中 是 没 有 问 题 的 , 但 是 假 如 引 用 了 s e l e c t 2 插 件 后 , 必 须 在 最 后 面 加 上 . s e l e c t 2 ( ) ; 如 : ("……").val(xxx);默认选中是没有问题的, 但是假如引用了select2插件后,必须在最后面加上.select2(); 如: ("……").val(xxx);默认选中是没有问题的,但是假如引用了select2插件后,必须在最后面加上.select2();如:("#123").val("***").select2(); -
克隆问题
在使用select2后必须加上$(“select”).select2(“destroy”);
$(“select”).removeAttr(“data-select2-id tabindex aria-hidden”);
$(“option”).removeAttr(“data-select2-id”);
//销毁select2,若不销毁,会导致克隆后不可selesc不可用s
在这里参考了https://blog.csdn.net/you23hai45/article/details/75715100
**