AngularJS aware click handler

3 posts, 0 answers
  1. Lars
    Lars avatar
    34 posts
    Member since:
    Feb 2011

    Posted 03 Nov 2014 Link to this post

    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. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2877 posts

    Posted 05 Nov 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2877 posts

    Posted 07 Nov 2014 Link to this post

    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!
     
Back to Top