Tha*_*dis 6 javascript jquery-select2 jquery-select2-4
我想为 select2 创建一个自定义数据适配器,但我在网上看到的示例都使用了 AMD。我们不在我们的项目中使用 AMD。如何创建我的自定义 dataAdapter?实现current和query方法的普通对象是不够的。
Select2 有一个内置的 AMD 加载器,用于加载插件和适配器,因此您需要使用它来构建自定义数据适配器。
您可以在 Select2 版本 4.x 中将装饰器添加到数据适配器中找到自定义数据适配器的示例
define您需要使用 中 Select2 提供的方法,而不是直接调用jQuery.fn.select2.amd。所以像
define('something/awesome', ['select2/data/array', function (ArrayAdapter) {
// Use the array adapter
}]);
Run Code Online (Sandbox Code Playgroud)
会成为
jQuery.fn.select2.amd.define('something/awesome', ['select2/data/array', function (ArrayAdapter) {
// Use the array adapter
}]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1653 次 |
| 最近记录: |