Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Safe $apply #27

Closed
ghost opened this issue Jun 25, 2013 · 10 comments
Closed

Safe $apply #27

ghost opened this issue Jun 25, 2013 · 10 comments
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Jun 25, 2013

Hi,

just wanted to mention that you should do a safe $apply() in line 95 and 195 respectively.
That is to prevent running $apply() when there is already one running.

You should do it this way: https://coderwall.com/p/ngisma

@ospatil
Copy link
Member

ospatil commented Jun 25, 2013

Yes, I too noticed it. Will add it soon.

@passelin
Copy link
Contributor

I have not used this trick here as I don't think it is necessary: the event handlers will always be invoked asynchronously by the kendo ui code. Have you come across a case where 2 event handlers were invoked synchronously by the kendo ui code? Until such a case is reported, I don't think we need to change this.

@ghost
Copy link
Author

ghost commented Jun 25, 2013

Well, I'm using a Kendo Grid with server paging/sorting/filtering, and I'm using k-on-change and k-on-data-bound to bind the selected row to the scope and retain the selection on page change. It's happening somewhere in there, as my console shows a '$digest() already in progess' error. If I do a safe $apply() everything is fine.

@passelin
Copy link
Contributor

Thanks, we'll look into this. Can you share a fiddle or plunker? You can start from here if you want: http://plnkr.co/edit/F3IFhf

@ghost
Copy link
Author

ghost commented Jun 25, 2013

Yes, I'll do it as soon as I get back into the office tomorrow. Thank you.

@ghost ghost assigned ospatil Jun 26, 2013
@treibholzhq
Copy link

Hi, here's the plunk: http://plnkr.co/edit/sUJUbU

I was a bit confused about the angular-kendo.js you used in your starting point posted above. It has 400+ lines of code, while the one I am using (https://github.com/kendo-labs/angular-kendo/blob/master/build/angular-kendo.js) only has 253 LoC. Anyway, please run my plunk in embedded view, select a row on first page, then switch to second page, then back to first again and you will find the row reselected. While doing this, please watch the console as it will give you an "Error: $apply already in progress" message.

Thanks!

ospatil added a commit that referenced this issue Jun 26, 2013
ospatil added a commit that referenced this issue Jun 27, 2013
@marklagendijk
Copy link
Contributor

An easier (and in my opinion, better) way is to use $timeout (without delay) in these cases:

$timeout(function(){
    // Do something
});

burkeholland added a commit that referenced this issue Jul 1, 2013
Changing the tagline

Add bower.json file

Specify main in bower.json

Remove dependency on jQuery

Update CHANGELOG

Corrected module name - from kendo to kendo.directives

Update widget.js

Currently the minified version (build/angular-kendo.min.js) is broken, because the 'minify-proof-dependency-injection-syntax' was forgotten here.
This pull requests fixes that issue.

Added missing packages

Changed to safe  for #27

Added safe apply for #27

Preparing for 0.5.1 release
@burkeholland
Copy link
Contributor

@marklagendijk Didn't I see this in another issue? I can't find the number.

@marklagendijk
Copy link
Contributor

@burkeholland I can't remember having seen this in an other angular-kendo issue, but I haven't read all of them :).

@burkeholland
Copy link
Contributor

Done and done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants