0

我有以下代码。获取所选值时,它工作正常。但是,如果我尝试将所选值置于任何条件下,它就会动摇。代码崩溃。

var onAcctMgrSelect = function (e) {
    // access the selected item via e.item (jQuery object)
    ddAMList = $("#ddAM").data("kendoDropDownList");
    if (ddAMList.value() == "0")
        $("#btnSearch").attr("class", "k-button  k-state-disabled");
    else
        $("#btnSearch").attr("class", "k-button");
    ///alert(ddAMList.text()); 
    checkValidData();
};

DropDownlist 代码如下:

function loadAccountManagers() {
    $("#ddAM").kendoDropDownList({
        change: onAcctMgrSelect,
        dataTextField: "AcctMgrFullName",
        dataValueField: "Id",
        dataSource: {
                schema: {
                    data: "d", // svc services return JSON in the following format { "d": <result> }. Specify how to get the result.
                    total: "count",
                    model: { // define the model of the data source. Required for validation and property types.
                        id: "Id",
                            fields: {
                                Id: { validation: { required: true }, type: "int" },
                                    AcctMgrFullName: { type: "string", validation: { required: true} }
                                    }
                           }
                        },
                transport: {
                read: {
                    url: "../services/Prospects.svc/GetAccountManagers", //specify the URL which data should return the records. This is the Read method of the Products.svc service.
                    contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
                    type: "GET" //use HTTP POST request as the default GET is not allowed for svc
                }
            }
        }
    });

I'm basically trying to disable the submit button if the first item is selected (which is a blank item in my case with a value of '0').

Am I going wrong anywhere? Please help!

4

0 回答 0