Skip to content

Inconsistent ApplicationView rendering issue #1010

Closed
commadelimited opened this Issue Jun 15, 2012 · 17 comments

10 participants

@commadelimited

I'm reading up on Ember.Router and found a fiddle written by @jbrown that illustrated the concept:

http://jsfiddle.net/justinbrown/C7LrM/10/

When I copied the code and ran it locally I found I was getting intermittent errors. It runs just fine once, then will error a few times in a row. This happens on a hard refresh, or a plain reload.

Here's my copy of the code as well as the full error stack.
Browser is Chrome 20.0.1132.27 beta
Mac OS X Lion 10.7.3 build 11D50

http://andymatthews.net/code/emberstatemanager/

Uncaught Error: <App.ApplicationView:ember266> - Unable to find template "application". ember-latest.js:11528
    Ember.View.Ember.Object.extend.templateForName ember-latest.js:11528
    Ember.View.Ember.Object.extend.template ember-latest.js:11476
    ComputedPropertyPrototype.get ember-latest.js:2138
    get ember-latest.js:1222
    Ember.View.Ember.Object.extend.render ember-latest.js:11776
    Ember.View.Ember.Object.extend.renderToBuffer ember-latest.js:12470
    Ember.View.Ember.Object.extend.createElement ember-latest.js:12267
    Ember.View.states.preRender.insertElement ember-latest.js:13055
    Ember.View.Ember.Object.extend.invokeForState ember-latest.js:11830
    invoke ember-latest.js:3439
    iter ember-latest.js:3486
    Ember.ArrayUtils.forEach ember-latest.js:433
    RunLoop.flush ember-latest.js:3540
    RunLoop.end ember-latest.js:3458
    Ember.run.end ember-latest.js:3638
    autorun
@SauliusB

Try to add initialize() to Application ready function. Then all views shall be ready.

App=Em.Application.create({
    ready: function () {
        this._super();
        App.initialize();
    }
});
@commadelimited

Update on this issue. I experience the same behavior on my PC at home with one addition. Sometimes the app partially loads with an additional error (or this error alone).

Windows 7
Chrome 21.0.1171.0 dev-m

Stack trace

Uncaught Error: <App.Router:ember169> could not respond to event unroutePath in state root. ember-latest.js:16716
    Ember.StateManager.Ember.State.extend.sendRecursively ember-latest.js:16716
    Ember.StateManager.Ember.State.extend.sendRecursively ember-latest.js:16714
    Ember.StateManager.Ember.State.extend.send ember-latest.js:16695
    Ember.Router.Ember.StateManager.extend.route ember-latest.js:17426
    Ember.Application.Ember.Namespace.extend.startRouting ember-latest.js:11835
    Ember.Application.Ember.Namespace.extend.initialize ember-latest.js:11800
    (anonymous function)
@commadelimited

@SauliusB that didn't seem to help. I was able to add an additional error message though. Oddness. Thanks for trying to help though.

@bradleypriest
Ember.js member

@commadelimited Are you using the latest master? If so, you need to change the instances of Ember.State to Ember.Route in your router.

@commadelimited

That's fair enough, but the more important question is why isn't @wagenet experiencing the same issue when viewing my code.

@wagenet
Ember.js member
wagenet commented Jul 9, 2012

@commadelimited The intermittent error would imply a timing issue. If it makes you feel any better, I just hit it.

@wagenet
Ember.js member
wagenet commented Jul 9, 2012

@commadelimited, @bradleypriest has the right direction here. The issue is that initialize is getting called before your templates are loaded. This should be fixed by moving your <script src="js/app.js"></script> to the end. However, it's worth considering if there's a better way for us to do this.

@commadelimited

Peter, do you mean the end of the page? I know that's best practice and all but I really hate doing that. Script tags belong on the head...old school and all.

@wagenet
Ember.js member
wagenet commented Jul 9, 2012

@commadelimited Yes, that's what I meant.

@hnan
hnan commented Jul 12, 2012

Moving the app.js to the end doesn't help. As @SauliusB said, Moving App.initialize()' into ready function solved the problem, for me at least.

@trek
Ember.js member
trek commented Jul 12, 2012

I think there's a hesitation to "fix" this within the library because it relates to bigger issues in web development and a particular application's environment: using a preprocessor, DOM-readiness, loading templates incrementally, etc.

There was discussion of checking at App.initialize time whether Handlebars had finished bootstrapping and issuing a warning so you'd at least know _why_you were getting this warning. Suggesting specific ways to to resolve the warning is probably beyond the scope of the framework.

@wagenet wagenet closed this in cbb61a5 Jul 17, 2012
@wagenet wagenet reopened this Jul 17, 2012
@wagenet
Ember.js member
wagenet commented Jul 17, 2012

Looks like I was mistaken. This isn't fixed yet.

@wagenet
Ember.js member
wagenet commented Jul 17, 2012

Nevermind, this should be fixed. My test for it was messed up.

@wagenet wagenet closed this Jul 17, 2012
@florinutz

this is not fixed

@purplegit

There seems to be some keyword or string formatting issues here. I worked around it by using template names like "app-handlebars" instead of "application" or "application.handlebars".

@petsagouris

I can confirm this is not fixed.
Moved the script tag to end of page and it works.

@josecardozo

I had this when learning ember from "Advice on & Instruction in the Use Of Ember.js" by Trek. It solves when moving the script to the end of the file. As from purplegit comment, it must be a coincidence... change the names does not solved for me.
I'm using local files:

  • ember-1.0.0-pre.2.js
  • handlebars-1.0.rc.1.js and
  • jquery-1.8.3.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.