为什么这个Ember.js应用程序在Firefox中失败? [英] Why does this Ember.js app fail in Firefox?

查看:71
本文介绍了为什么这个Ember.js应用程序在Firefox中失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的Ember.js应用程序,在IE和Chrome中正常工作,但在Firefox(9.0.1和10.0)中失败。有什么原因吗以下是代码:

 <!doctype html> 

< html>
< head>
< title>模板名称< / title>
< / head>
< body>
< script type =text / x-handlebarsdata-template-name =my-template>
{{App.user.name}}
< / script>

< div id =container>< / div>

< script type =text / javascriptsrc =http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js>< ; /脚本>
< script type =text / javascriptsrc =http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.4.js>< / script>

< script type =text / javascript>
window.App = Ember.Application.create();

App.user = Ember.Object.create({
name:'John'
});

App.view = Ember.View.create({
templateName:'my-template'
});

App.view.appendTo('#container');
< / script>
< / body>
< / html>


解决方案

firefox中的错误是

 未捕获异常:错误:&Ember.View:ember143> - 无法找到模板我的模板。 

这似乎表明模板脚本在应用程序执行时尚未被评估。解决方案是等待onload。如下所示:

b $ b App.view.appendTo('#container');
});


I have a very simple Ember.js app which works correctly in IE and Chrome, but fails in Firefox (9.0.1 and 10.0). Any reason why? Here's the code:

<!doctype html>

<html>
<head>
    <title>Template Name</title>
</head>
<body>
    <script type="text/x-handlebars" data-template-name="my-template">
        {{App.user.name}}
    </script>

    <div id="container"></div>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.4.js"></script>

    <script type="text/javascript">
        window.App = Ember.Application.create();

        App.user = Ember.Object.create({
            name: 'John'
        });

        App.view = Ember.View.create({
            templateName: 'my-template'
        });

        App.view.appendTo('#container');
    </script>
</body>
</html>

解决方案

The error in firefox is

uncaught exception: Error: <Ember.View:ember143> - Unable to find template "my-template".

This would seem to indicate that the template script has not been evaluated at the point where the app executes. The solution is to wait for onload. Wrap your appendTo like this:

$(function() {
    App.view.appendTo('#container');
});

这篇关于为什么这个Ember.js应用程序在Firefox中失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆