Advertisement
Guest User

Untitled

a guest
Aug 24th, 2014
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     (function () {
  2.         /**
  3.          * a plugin for kendo that will return a .dataItem() from a widget
  4.          * if it is available, and bind it to a model property on the current
  5.          * scope.
  6.          **/
  7.         angular.module('ui.kendo', ['kendo.directives'])
  8.             .directive("kDataItem", ["$parse", function ($parse) {
  9.                 return {
  10.                     restrict: "A",
  11.                     scope: false,
  12.                     link: function (scope, element, attributes) {
  13.                         var getter = $parse(attributes.kDataItem);
  14.                         var setter = getter.assign;
  15.  
  16.                         scope.$on('kendoWidgetCreated', function (event, widget) {
  17.                             if ($.compare(widget.element, element)) {
  18.                                 widget.bind('change', function (e) {
  19.                                     scope.$apply(function () {
  20.                                         setter(scope, e.sender.dataItem().toJSON());
  21.                                     });
  22.                                 });
  23.                             }
  24.                         });
  25.                     }
  26.                 }
  27.             }]);
  28.     })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement