attr help

2 posts, 0 answers
  1. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 29 Mar 2012 Link to this post

    i am trying to disable a drop down list control

    here is the code

    $("#payment").attr('disabled', 'disabled');

    this does not seem to happen at all

    here is the payment control

    <label for="payments">Payment Type:&nbsp;&nbsp;&nbsp;</label><input id="payment" data-bind="value: payment" name="payment" />

    and the code load the datasource
    $.ajax({
                                    url: 'dsr.asmx/get_Payment',
                                    async: true,
                                    cache: false,
                                    timeout: 30000,
                                    contentType: 'application/json; charset=utf-8',
                                    data: "{}",
                                    type: 'POST',
                                    dataType: 'json',
                                    success: function (msg) {
                                        $("#payment").val("revpay").kendoDropDownList({
                                            index: 0,
                                            optionLabel: "Select Payment Type",
                                            dataTextField: "Description",
                                            dataValueField: "Code",
                                            filter: "contains",
                                            suggest: true,
                                            minLenght: 1,
                                            change: onPayChange,
                                            dataSource: {
                                                data: msg.d
     
                                            }
                                        });
                                    }
                                });

    and the function to disable the control by another drop down list choice
    function onResChange() {
                   var res = document.getElementById("result").value;
                   switch (res) {
                       case 'c':
                           alert('Canceled');
                           $("#payment").attr('disabled', 'disabled');
                           break;
                       case 'cb':
                           alert('Call Back no Sale');
                           break;
                   }
               }

    the alert's work but the .attr is never firing
  2. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 29 Mar 2012 Link to this post

    i found it under the documentation for the drop down list under configuration

    Drop Down List Configuration

    here is the answer

    var dropdownlist = $("#dropdownlist").data("kendoDropDownList");
    // disable the dropdown
    dropdownlist.enable(false);
  3. Kendo UI is VS 2017 Ready
Back to Top