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

bindToKNgModel - unnecessary $apply

3 Answers 46 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 16 Jun 2015, 08:56 AM

Hi,

is it possible that you have one unnecessary $apply function inside mentioned method. In there you have:

// keep in sync
        scope.$apply(function() {
            var watchHandler = function(newValue, oldValue) {
                if (newValue === undefined) {
                    // because widget's value() method usually checks if the new value is undefined,
                    // in which case it returns the current value rather than clearing the field.
                    // https://github.com/telerik/kendo-ui-core/issues/299
                    newValue = null;
                }
                if (updating) {
                    return;
                }
                if (newValue === oldValue) {
                    return;
                }
                widget.$angular_setLogicValue(newValue);
            };
            if (kendo.ui.MultiSelect && widget instanceof kendo.ui.MultiSelect) {
                scope.$watchCollection(kNgModel, watchHandler);
            } else {
                scope.$watch(kNgModel, watchHandler);
            }
        });

this is causing issues for us as we have some wrapper around kendo-tooltip where we manually compile content of it because it's dynamic (we get $digest already in progress issue). 

So, to get back on the code, why are you using $apply here? You only have two watch statements assigned, which don't require $apply around it.

3 Answers, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
answered on 16 Jun 2015, 09:49 AM
Addition to previous question. Here is the exception:

Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.2.28/$rootScope/inprog?p0=%24digest
    at angular-1.2.28.js:78
    at beginPhase (angular-1.2.28.js:13122)
    at Scope.$apply (angular-1.2.28.js:12908)
    at bindToKNgModel (all.min.2015.1.429.js:113036)
    at createIt (all.min.2015.1.429.js:112869)
    at createWidget (all.min.2015.1.429.js:112754)
    at all.min.2015.1.429.js:113257
    at $timeout (all.min.2015.1.429.js:112653)
    at create.link (all.min.2015.1.429.js:113253)
    at nodeLinkFn (angular-1.2.28.js:6752)

 

Can you, at least check in bindToKNgModel check if scope.$$phase or scope.$root.$$phase is undefined? We are getting $rootScope digest issue, we shouldn't be getting that because of simple $compile.

0
Jason
Top achievements
Rank 1
answered on 16 Jun 2015, 09:56 AM
(why there is not edit? :))

One additional note. This happened when we upgraded Kendo from 2014.2.903 to 2015.1.429...
0
Petyo
Telerik team
answered on 17 Jun 2015, 09:08 AM
Hello,

the $scope.$apply call is an unnecessary thing which we decided to remove as a part of a bigger cleanup. You can check what we did in this commit.

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