问题描述:

So what I'm trying to do is disable a button when it gets clicked, and those buttons ( there are of course more of them being generated and displayed in table cells ) along with other tabular data are generated by Kendo UI Grid Angular script.

HTML for Kendo UI Grid:

 <div kendo-grid="SearchGrid" options="mainGridOptions"

k-rebind="mainGridOptions" id="grid-cs"></div>

Angular code / controller for generating Kendo UI Grid (I won't pass all the other field names because they're just strings, this "Subscribe" field is important since it generates a button which is causing me headaches):

 myapp.controller("MyCtrl", function ($scope, $http) {

$scope.disableButton = function($event) {

var btn = $($event.target);

btn.attr({

'disabled': true

});

};

$scope.myButton = "<button kendo-button

ng-click='disableButton($event)'

value='Add Subscription'

class='k-button k-button-icontext k-grid-Details'>

Add Subscription

</button>";

$scope.mainGridOptions = {

dataSource: "",

columns:[

{

title: "Subscribe",

command: [{

template: $scope.myButton

}]

}

]

};

});

I get a couple of buttons displayed in DOM ( which is okay ), and when I click on any random button for the first time, it will not disable it, however, when I click on second and n-th time after it on a random button, it works great ( disable function does its work ), and any button being clicked after that 2nd time does get disabled too. The problem lies in that first event trigger / first click, which is not working properly. Hope that anyone had the same problem too and solved it? Tnx!

相关阅读:
Top