选择下拉列表不能正常工作 [英] chosen dropdown not Working properly

查看:93
本文介绍了选择下拉列表不能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在MVC中有一个下拉菜单,比如


I have a dropdown in MVC like

@Html.DropDownList("CompanyID", null, "Select Company", new { onchange = "GetDiv()" })
 @Html.DropDownList("WarehouseID",null, new { @class = "warehouse-select" })





点击第一个下拉列表将调用javascript函数并将相关数据绑定到第二个下拉列表。

所以,这是我的javascript,其中我使用了插件



here on click of first dropdown a javascript function will be called and bind related data to second dropdown.
so, here is my javascript where i used plugin

function GetDiv() {
        debugger;
        var warehouseno = $("#CompanyID").val();
        $.ajax(
        {
            type: "POST",
            url: "@Url.Action("GetWarehouseDropdown", "SearchJDE")",
            dataType: 'json',
            data: { id: warehouseno },
            success: function (result) {
                //$("#WarehouseID").html("");
                for (var i = 0; i < result.length; i++)
                {
                    var item = result[i];
                    $('ul.chzn-results').append('<ul><li class="active-result">' + item.Text + '</li></ul>').css({ "width": "288px" });                    
                }               
            },
            error: function (req, status, error) {
                alert(error);
            }
        });
    }





我成功将数据绑定到下拉列表但选择的插件无法正常工作 。我无法在下拉列表中看到所选值,甚至搜索框也不可用,如单一选择

http://harvesthq.github.io/chosen/ [ ^ ]

请帮助我。



I am successful in binding data to dropdown but chosen plugin is not working properly.I am not able to see selected value in dropdown, and even search box is also not availabla like single select
http://harvesthq.github.io/chosen/[^]
Please help me.

推荐答案

(#CompanyID)。val();
("#CompanyID").val();


.ajax(
{
type:POST,
url:@ Url.Action(GetWarehouseDropdown,SearchJDE),
dataType: 'json',
data:{id:warehouseno},
success:function(result){
//
.ajax( { type: "POST", url: "@Url.Action("GetWarehouseDropdown", "SearchJDE")", dataType: 'json', data: { id: warehouseno }, success: function (result) { //


(#WarehouseID) .html();
for(var i = 0; i< result.length; i ++)
{
var item = result [i];
("#WarehouseID").html(""); for (var i = 0; i < result.length; i++) { var item = result[i];


这篇关于选择下拉列表不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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