-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix to getTemplate(), $http instead of $.ajax() #347
Conversation
For some, reason if a template is fetched with $.ajax() and it receives a 304, a "$digest is already running" error will occur while it is trying to add it with $templateCache. Moving over to $http to do the get request seems to have fixed it.
the only problem with doing it async, is that the grid will continue to process and set it self up without the templates in some cases (laggy connections and such). I couldn't find a clean way to have $http do a synchronous call. |
OK, I see. Well:
|
This plunker will eventually demonstrate it, in FF, if you refresh it enough: http://run.plnkr.co/plunks/KCpCbE/ I can't get it to reproduce in Chrome, so maybe it could be the hack they put in for FF 20? |
Also, if there are two grids using the same rowTemplate you'll end up fetching the same URI twice. Additionally, is there a reason for pre-pending the gridId to the cache key for the template? Wouldn't the URI suffice? |
OK, I have a new fix, and a "test" demonstrating the error. I actually found it impossible to write a proper angular test (either via unit, midway, or e2e) that would demonstrate an exception being thrown because of intersecting XHRs. Anyway, here is the relevant branch: c0bra/ng-grid/fix-external-templates. There's a new test in workbench/templating that will demonstrate the error. You have to install express (now in the devDependencies), and run scripts/server.js. Then navigate to http://localhost:8000/workbench/templating/external.html. If you watch the console it should show an $apply error. This is because the express server is forcing the template to come back AFTER the data from the resource. The fix I implemented was to make If you run I can send a pull request if this all looks good to you. |
Closed with 2.0.5 release. |
For some reason if an external template (row/cell or header I would guess) is fetched with $.ajax(), and it receives a 304 (not modified) response, a "$digest is already running" error will occur while it is trying to add it to $templateCache.
Moving over to $http to do the get request seems to have fixed it. Was there a reason for the jquery/jquery-ish method?
I'd like to add a test for this, if possible, but it has been randomly breaking my app as 304s occasionally happen so I thought I would submit the pull request for now.