1

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>
4

1 に答える 1

2

この質問を見てください:誰かが最新のルーティング システムを使用する ember.js プロジェクトを教えてくれませんか? ember-data を使用している場合のボーナス ポイントと、優れたアプリの例がいくつかあります。

私は個人的にこれが本当に好きです:

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

ファイルを構造化し、アプリの開発と展開に最新のツールを使用する方法についての良いアイデアを提供します。

于 2013-01-28T12:32:14.057 に答える