问题来自AJAX调用显示引导多选下拉列表中的数据返回 [英] Issue with Data returning from AJAX call showing up in Bootstrap Multiselect dropdown

查看:122
本文介绍了问题来自AJAX调用显示引导多选下拉列表中的数据返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的引导多选从 http://davidstutz.github.io/bootstrap -multiselect /#工具入门

不过,我的下拉没有显示我的结果...甚至在下降为此事。不知道这有什么差别,但我在一个模式使用此,我沿着侧AngularJS用这个。

However, my dropdown is not showing my results...or even dropping down for that matter. Not sure if it makes any difference, but I am using this in a Modal and I am using this along side AngularJS.

这是我应该把我的HTML页面上(根据上述网站):

This is all I should have to put on my HTML page (according to the website above):

<select id="primaryCategory-dropdown" multiple="multiple"></select>

我提出以下AJAX调用我的服务:

I am making the following AJAX call to my service:

function loadPrimaryCategories() {

    $.ajax({
        url: '/Portal/api/PrimaryCategories/GetAll',
        type: 'GET',
        dataType: 'json',
        success: function (data) {     
            $.each(data, function(i, primaryCategory) {
                $("#primaryCategory-dropdown").append('<option value="' + primaryCategory.Id + '">' + primaryCategory.Name + '</option>');
            });
        },
        error: function(data) {
            alert(data);
        }
    });
}

我获得返回结果(我有57确切的说):

I am getting results back(I have 57 to be exact):

<option value="1">2004 Examination

<option value="2">341 Meeting

<option value="3">Abandonment

但按钮不会打开,显示我的结果。它会启用和禁用时,我一下就可以了。您还可以看到一个滚动列表框中显示的所有值当我改变了风格=显示:块。它似乎像没有正确的结合。

But the button does not open to show my results. It will enable and disable when I click on it. You can also see a scroll list box appear with all the values when I change the style='display: block'. It almost seems like it isn't binding properly.

我下面的这个例子中,相同的指令,但是一旦我实现它变成我的解决方案不起作用: HTTPS ://jsfiddle.net/3p3ymwwc/

I am following the same instructions as this example, but once I implement it into my solution it doesn't work: https://jsfiddle.net/3p3ymwwc/

推荐答案

我试着用 $(#ddlState)多选('刷新');
 但它并没有为我工作。

I tried with $("#ddlState").multiselect('refresh'); but it didn't work for me.

但是,当我取代刷新与重建它的工作原理:

But when I replaced 'refresh' with 'rebuild' it works:

$("#ddlState").multiselect('rebuild');

这篇关于问题来自AJAX调用显示引导多选下拉列表中的数据返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆