Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用selectize删除所需属性_Javascript_Jquery_Html_Checkbox_Selectize.js - Fatal编程技术网

Javascript 使用selectize删除所需属性

Javascript 使用selectize删除所需属性,javascript,jquery,html,checkbox,selectize.js,Javascript,Jquery,Html,Checkbox,Selectize.js,我使用selectize选择多个国家/地区。我有一个复选框来选择所有国家 现在,如果以这种方式选中复选框,我将禁用selectize字段 $("#outbound_countries").selectize({ delimeter: ',', plugins: ['remove_button'], persist: false, create: function(input) {

我使用selectize选择多个国家/地区。我有一个复选框来选择所有国家

现在,如果以这种方式选中复选框,我将禁用selectize字段

$("#outbound_countries").selectize({
            delimeter: ',',
            plugins: ['remove_button'],
            persist: false,
            create: function(input) {
                return {
                    value: input,
                    text: input
                }
            }
        });
这是我的html页面

<div class="form-group">
        <label for="outbound_countries" class="col-sm-3 control-label"> Outbound SMS Countries: </label>
        <div class="col-sm-4">
            <select id="outbound_countries" name="outbound_sms_countries" class="form-control" multiple required enabled />
            {% for country in country_list %}
                <option value="{{country.iso}}">
                    {{ country.printable_name }}
                </option>
            {% endfor %}
            </select>
            <input type="checkbox" name="outbound_all_countries" id="outbound_all_countries" required /> All Countries
        </div>
    </div>

出站SMS国家/地区:
{国家/地区中的国家/地区的%u列表%}
{{country.printable_name}
{%endfor%}
所有国家
所以对于复选框和选择字段,我都有必需的属性。如果选中该复选框,如何使用selectize删除所需的属性


此外,如果我在选择框中选择了国家,我如何使用selectize从该选择框中获取所选值?

您可以使用selectz用于选择selectz multiple的代码

var Selectz = require('selectize');


Selectz.define('no-delete', function(option) {
  this.deleteSelection = function() {};
});


$("select[name='State-code']").selectz({
    plugins:{
        'no-delete': {}
    },
});

您可以使用selectz用于选择selectz多个的代码

var Selectz = require('selectize');


Selectz.define('no-delete', function(option) {
  this.deleteSelection = function() {};
});


$("select[name='State-code']").selectz({
    plugins:{
        'no-delete': {}
    },
});