vitalets / angular-xeditable

Edit in place for AngularJS
http://vitalets.github.io/angular-xeditable
MIT License
1.91k stars 403 forks source link

ng-Table with x-editable e-single is giving 10 $digest() iterations reached. Aborting! #455

Open Pavan1889 opened 8 years ago

Pavan1889 commented 8 years ago

in my form i have table with 2 texts and 3 dropdowns which are editable-select but i have debugged and came to know that beacuse of the function showStatus() which is calling many times. in my case it is executing for 124 times. and finally in console throwing an error "10 $digest() iterations reached. Aborting!" i have forked the original editable-select in my case: http://jsfiddle.net/Pavan1889/q44qfcj8/

[$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [[{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":{"Value":null}},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":{"Value":null}},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":{"Value":null}},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":{"Value":null}}],[{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."}],[{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."}],[{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."}],[{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."},{"msg":"fn: ngModelWatch","newVal":{"Value":null},"oldVal":"..."}]]

ckosloski commented 8 years ago

What exactly did you change in your JSFiddle? I looked at it and nothing was jumping out at me.

Pavan1889 commented 8 years ago

Sorry im not available online from past 2 weeks, any how check the below for issue:

http://jsfiddle.net/Pavan1889/q44qfcj8/1/

Pavan1889 commented 8 years ago

Hi i have made one more fiddle resembling my issue :

http://jsfiddle.net/Pavan1889/vraounop/1/

ckosloski commented 8 years ago

Looking at your latest fiddle, I see several errors in the console relating to ng-table.

Error: pData.then(...).catch is not a function NgTableParams/this.reload@https://cdn.rawgit.com/esvit/ng-table/master/dist/ng-table.js:1101:1

Error: Template must have exactly one root element.

ckosloski commented 8 years ago

I think your issue is due to normal angular behavior. This {{showStatus()}} creates a watcher and anytime there is a digest, the showStatus function gets called.

I verified this by printing out the stack trace of the call every time it was called:

at Scope.$scope.showStatus ((index):302) at fn (eval at (angular.js:14086), :4:221) at expressionInputWatch (angular.js:15116) at Scope.$digest (angular.js:16655) at Scope.$apply (angular.js:16928) at HTMLAnchorElement. (xeditable.min.js:6) at defaultHandlerWrapper (angular.js:3398) at HTMLAnchorElement.eventHandler (angular.js:3386)

I think what you need to do is do a one way binding on the initial text display and then update the text via a function call with the onaftersave attribute.

Check out this version of your jsfiddle.

Pavan1889 commented 8 years ago

Hi i did the same, but i ended up like this???

http://jsfiddle.net/Pavan1889/q44qfcj8/3/

https://jsfiddle.net/Pavan1889/6a71bu7g/1/

where i am going wrong?

ckosloski commented 8 years ago

You need angular version 1.3 or higher. That is when the single way binding was introduced.

ckosloski commented 8 years ago

Try with the latest version which contains changes to scope which may fix your issue.