This is a migrated thread and some comments may be shown as answers.

AngularJS aware click handler

2 Answers 133 Views
Toolbar
This is a migrated thread and some comments may be shown as answers.
Lars
Top achievements
Rank 1
Lars asked on 03 Nov 2014, 05:39 PM
Hello,

Is there a way to define something like an AngularJs ng-click handler  for your toolbar buttons, so that you don't have to manually call $apply?

As an example, here is what I currently do:
$scope.paymentToolbarOptions = {
    items: [{
    type: "button", id: "manualIr", text: "Manual IR", overflow: "always"
    }...],
    click: function (e) {
        if (e.id === "manualIr") {
         $scope.$apply(function() { $scope.payManualIr(); });
        }
  }
};

Thanks,
Lars


2 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 05 Nov 2014, 01:08 PM
Hello Lars,

Thank you for the feedback. We will add this enhancement in the official release which is scheduled in about two weeks.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Alexander Valchev
Telerik team
answered on 07 Nov 2014, 02:55 PM
Hello Lars,

Upon further investigation we decided to reject this enhancement. Initially we though that you speak about the click configuration option of the ToolBar's items however according to the provided code snippet you use the ToolBar's "global" click event.

By default widget's event handlers are wrapped in $scope.apply only if they are bound using the k-on-<event name> attribute. In case the developer defines the event handler directly in the options object he/she is responsible for calling manually $scope.apply. This is written in the documentation:
The click configuration option of the toolbar item however cannot be set via k-on-<event name> attribute and implementing automatically wrapping will lead to inconsistent behavior.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Toolbar
Asked by
Lars
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or