• select2的相关问题


    在弹出框中无法使用select2的问题:

    通常情况下,使用select2只需要在加载相关js和css后,添加如下代码即可:

    $("#selectId").select2();

    但如果这个select在弹出框中,这样使用往往是无效的,这时候需要这样写:

    $.fn.modal.Constructor.prototype.enforceFocus = function () {$("#selectId").select2(); };

    参考https://github.com/select2/select2/issues/1436

    select2设置默认选中:

    设置value为pxx的项选中 

    $('#area').val(pxx).trigger("change");

     设置text为pxx的项选中 

    $("#area").find("option[text='pxx']").attr("selected",true).trigger("change");

    上面代码无效,要使用下面代码

    $("#area option").filter(function(){return $(this).text()=='pxx';}).prop("selected",true).trigger("change");

    (使用默认select不需要.trigger("change"))

    多个select2示例化,并且某个select2需要ajax获取数据时,需将ajax获取数据的select2放到最后实例化,否则无效

    $('.select2').select2();
    $('.select2_required').select2({allowClear:false});
    $('#create_by').select2({}, "{:url('ajaxGetUserList')}");
  • 相关阅读:
    六.Linux其他命令
    五.Linux压缩文件的操作命令(压缩解压)
    sigaction
    log_note log_error log_warning
    SIGHUP
    pthread_create
    semaphore
    getpwuid
    close port
    pthread
  • 原文地址:https://www.cnblogs.com/dreamydeng/p/5822435.html
Copyright © 2020-2023  润新知