本文介绍了如何清除选定的值selectize.js下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个selectize.js下拉菜单&我必须清除所选的值。



我试过:

  var selectize = $(#optionNetFlow)[0] .selectize; 
selectize.clear();

如另一个问题所示



什么对我有用的是:

  var $ select = $('#optionNetFlow')。selectize(); 
var control = $ select [0] .selectize;
control.clear();

我缺少的东西 var $ select = $('#optionNetFlow') .selectize(); 在应用上述问题答案中提供的解决方案之前。



现在我要在控制台中获取所有功能: / p>


I have a selectize.js dropdown & I have to clear the selected value .

I have tried :

var selectize = $("#optionNetFlow")[0].selectize;
selectize.clear();

as suggested in an another question How do I set the selectize.js option List programmatically. But it gives an error,

Uncaught TypeError: Cannot read property 'selectize' of undefinedmessage: "Cannot read property 'selectize' of undefined"stack: (...)get stack: function () { [native code] }arguments: nullcaller: nulllength: 0name: ""prototype: StackTraceGetterconstructor: function () { [native code] }__proto__: Object__proto__: function Empty() {}<function scope>set stack: function () { [native code] }__proto__: Error

when I change it to :

    var selectize = $("#optionNetFlow").selectize;
    selectize.clear();

I gives error:

TypeError: undefined is not a functionmessage: "undefined is not a function"stack: (...)get stack: function () { [native code] }set stack: function () { [native code] }__proto__: Error VM1253:3(anonymous function) VM1253:3InjectedScript._evaluateOn VM1251:732InjectedScript._evaluateAndWrap VM1251:665InjectedScript.evaluate VM1251:579

what I am doing wrong here?

解决方案

I finally found the answer here Selectize.js Demos

What works for me is:

 var $select = $('#optionNetFlow').selectize();
 var control = $select[0].selectize;
 control.clear();

what I was missing var $select = $('#optionNetFlow').selectize(); before applying the solution provided in above question's answer.

Now I am to get all the functions in console like :

这篇关于如何清除选定的值selectize.js下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 03:10