选择后,选择2随机播放选项

时间:2017-01-05 06:36:36

标签: jquery jquery-select2

我正在使用select2插件。

在jsfiddle上它运行正常。 但这是解释我的问题的截图,

  1. 这是下拉列表的默认顺序。
  2. default order

    1. 当我选择其他选项时,例如无效,则转到最后一个选项。
    2. inactive selected

      1. 选中后检查无效位置。
      2. check inactive option position

        每个选项都会发生这种情况。

        我尝试了以下替代方案,

        • x
        • long n = 1000000000000000L; int zeroBitsCount = 0; while (n > 0) { if (n % 2 == 0) { zeroBitsCount++; // counts the number of non-leading 0 bits } n = n >> 1; // divide n by 2 in order to examine the next bit in the next iteration } long total = 1L << zeroBitsCount; // the total is 2^(the 0 bits count)
        • $("select").select2();

        但没有任何作用,

        是否有人遇到此问题?

        如果是,请帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

我刚刚找到解决方案,

$("select").on("select2:select", function(evt) {
        var element = evt.params.data.element;
        var $element = $(element);
        $element.detach();
        $(this).append($element);
        $(this).trigger("change");
});

这是用于其他目的的代码,但保存在常见的js文件中。

我把它转移到它特别属于的地方。

相关问题