【问题标题】:Validating Ember.js architecture验证 Ember.js 架构
【发布时间】:2013-01-28 12:09:38
【问题描述】:

我正在努力适应 Ember.js 架构的布局。有人可以给我一些提示和技巧,让我了解如何以最合适的方式构建我的应用程序。

<html>
    <head>
        <script src="../script/library/jquery.js"></script>
        <script src="../script/library/handlebars.js"></script>
        <script src="../script/library/ember.js"></script>
        <script>
            $(document).ready(function(){
                Application = Ember.Application.create();

                Application.ApplicationView = Ember.View.extend({
                    templateName: 'application'
                });

                Application.ApplicationController = Ember.Controller.extend();

                Application.Cat = Ember.Object.extend({
                    name: null,
                    breed: null
                });

                Application.CatView = Ember.View.extend({
                    templateName: 'catCreate'
                });

                Application.CatController = Ember.Controller.extend({
                    content: null,
                    create: function() {
                        alert("controller uploading: " + this.get('content').name);
                    }
                });

                Application.Router = Ember.Router.extend({
                    root: Ember.Route.extend({
                        createCat: Ember.Route.extend({
                            route: '/',
                            connectOutlets: function(router) {
                                router.get('applicationController').connectOutlet('cat', Application.Cat.create());
                            }
                        })
                    })
                });

                Application.initialize();
            });

        </script>
    </head>
<body lang="en">
    <script type="text/x-handlebars" data-template-name="application">
        {{outlet}}
    </script>

    <script type="text/x-handlebars" data-template-name="catCreate">
        <h1>Cat Detail</h1>
        {{view Ember.TextField id="name" valueBinding="content.name"}}<br/>
        {{view Ember.TextField id="breed" valueBinding="content.breed"}}<br/>
        <button {{action "create" target="controller"}}>Done</button>
    </script>
</body>
</html>

【问题讨论】:

    标签: javascript html model-view-controller ember.js


    【解决方案1】:

    看看这个问题:Could someone point me to an ember.js project that uses the latest routing system? Bonus points if it uses ember-data as well 有一些不错的应用示例。

    我个人非常喜欢这个:

    https://github.com/trek/ember-todos-with-build-tools-tests-and-other-modern-conveniences

    它为您提供了有关如何构建文件和使用现代工具开发和部署应用程序的好主意。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-17
      • 2010-10-22
      • 2012-05-29
      • 2010-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      相关资源
      最近更新 更多