Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Web applications with Ember.js

Tags:

ember.js

I've just found out about Ember.js, and it looks interesting. I'd like to create a small notes app to learn how to use it.

The basic layout I have in mind is to have categories, and each category can have notes. For the UI, there would be a sidebar with the categories which will be clickable, and the notes for the category will be displayed on the other side.

But I can't quite figure out the whole template/layout system. The template system itself seems simple enough (similar enough to Rails views). But what do you do for layouts? With Rails for example, you can define layouts quite easily and then the individual views are added to that. This seems unclear to me with Ember.js.

like image 783
user1423402 Avatar asked May 29 '12 10:05

user1423402


People also ask

How to create a simple app using Emberjs?

Let us create one simple app using Ember.js. First create one folder where you create your applications. For instance, if you have created the "emberjs-app" folder, then navigate to this folder as − Inside the "emberjs=app" folder, create a new project by using the new command −

How to create a new project folder in Ember?

Step 1: Now you have access to a new command in the terminal. You can use the ember new command to create a new app. This command can create a new directory in your system. Step 2: After creating your project folder i.e. <project-name>, move to it using the following command.

How to run the Ember app using Ember-CLI-build?

ember-cli-build.js − It specifies how to build the app by using the Ember CLI. To run the application, navigate to the newly created project directory − We have created the new project and it is ready to run with the command given below − Now open the browser and navigate to http://localhost:4200/.

What is Ember web developer?

web developers. Ember.js is a productive, battle-tested JavaScript framework for building modern web applications. It includes everything you need to build rich UIs that work on any device.


1 Answers

Besides the approaches @rharper mentioned, you can also use the outlet helper, wich has been introduced in commit 5a4917b.

You can find an example here:

Handlebars:

<script type="text/x-handlebars" data-template-name="main" >
    Main View
    {{outlet contentView}}
    {{outlet footerView}}
</script>

JavaScript:

App.viewController = Ember.Object.create({
    footerView: Ember.View.create({
        templateName: 'footer'
    }),
    contentView: Ember.View.create({
        templateName: 'content'
    })
});

Ember.View.create({
    controllerBinding: 'App.viewController',
    templateName: 'main'
}).append();

Ember.run.later(function(){
    App.viewController.set('contentView', Ember.View.create({
        templateName: 'new-content'
    }));
}, 1000);

like image 85
pangratz Avatar answered Sep 22 '22 01:09

pangratz