AngularJS - manually calling $scope.$apply

6 posts, 0 answers
  1. Nick
    Nick avatar
    31 posts
    Member since:
    Oct 2011

    Posted 21 Aug 2014 Link to this post

    If I modify the scope from a callback (data-k-dragend="onDragEnd") then it seems I have to manually call $scope.$apply.  I had assumed that KendoUI with the AngularJS integration would automatically wrap this for me.  Can you confirm if I'm doing something wrong or if this is planned to be fixed in a future release?

    Thanks!

      Nick
  2. Mihai
    Admin
    Mihai avatar
    153 posts

    Posted 22 Aug 2014 Link to this post

    Hi Nick,

    You can prefix event handlers with "k-on-", i.e. for your case that would be: k-on-dragend="onDragEnd($kendoEvent)".  See documentation.

    If you use the "k-on-" prefix, scope digesting will be handled for your automatically.  Note that you need to pass an expression, not a function reference -- it will only be evaluated when the event is triggered.

    Regards,
    Mihai
    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. Andrei
    Andrei avatar
    5 posts
    Member since:
    Aug 2014

    Posted 26 Aug 2014 in reply to Mihai Link to this post

    I try to using k-on-dragend
    <div kendo-tree-view="treeView"
                             k-data-source="treeMenu"
                             k-template="itemTemplateMenu"
                             k-drag-and-drop="true"
                             k-on-dragend="onDragEndEvent(kendoEvent)"
                             k-on-change="onTreeSelect(kendoEvent)"
                             k-drop="onTreeDrop"></div>

    and get current error:

    at Object.<anonymous> (http://localhost:6247/Scripts/kendo/2014.2.716/kendo.all.min.js:42:11940)
    at n.(anonymous function) (http://localhost:6247/Scripts/kendo/2014.2.716/kendo.all.min.js:42:6882)
    at Object.r.apply.next (http://localhost:6247/Scripts/kendo/2014.2.716/kendo.all.min.js:42:6921)
    at Object.<anonymous> (http://localhost:6247/Scripts/kendo/2014.2.716/kendo.all.min.js:42:12174)
    at n.(anonymous function) (http://localhost:6247/Scripts/kendo/2014.2.716/kendo.all.min.js:42:6882)
    at Object.r.apply.next (http://localhost:6247/Scripts/kendo/2014.2.716/kendo.angular.min.js:9:1906)
    at Object.<anonymous> (http://localhost:6247/Scripts/kendo/2014.2.716/kendo.angular.min.js:9:7159)
    at n.(anonymous function) [as $angular_makeEventHandler] (http://localhost:6247/Scripts/kendo/2014.2.716/kendo.angular.min.js:9:1867)
    at Object.<anonymous> (http://localhost:6247/Scripts/kendo/2014.2.716/kendo.angular.min.js:9:6822)
    at n.(anonymous function) [as $angular_init] (http://localhost:6247/Scripts/kendo/2014.2.716/kendo.angular.min.js:9:1867)
  5. Andrei
    Andrei avatar
    5 posts
    Member since:
    Aug 2014

    Posted 27 Aug 2014 in reply to Andrei Link to this post

    this error:  TypeError: undefined is not a function
  6. Mihai
    Admin
    Mihai avatar
    153 posts

    Posted 27 Aug 2014 Link to this post

    Hi,

    It works for me, here's a sample: http://dojo.telerik.com/OweG -- it dumps the kendoEvent with console.log on "dragend".

    The error message you pasted doesn't help to identify the problem.  If you can still encounter the issue please provide a simple test case at http://dojo.telerik.com/

    Regards,
    Mihai
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  7. Andrei
    Andrei avatar
    5 posts
    Member since:
    Aug 2014

    Posted 27 Aug 2014 in reply to Mihai Link to this post

    thank you  for example. I found problem.  I added script kendo.angular.min.js with kendo.all.min.js
Back to Top
Kendo UI is VS 2017 Ready