chrmod at warsawjs

We talk about JavaScript. Each month in Warsaw, Poland.

Ember.js for multipage applications

Krzysztof Modras @chrmod

So you have some Big, Tasty jQuery

You've ended with little CB hell?

                $(document).ready(function () {
                  $('#click-it-please").on('click', function () {
                    $(this).hide('slow', function () {
                      i guess here you have some black business magic 
                    });
                  });
                }
            

Captain Tomster for the resque!

In fact it's pretty easy to start

              // app.js
              App = Ember.Application.create({
                rootElement: "#content"
              });
              // in template
              <script type="text/x-handlebars">
                some nice handlebars template
              </script>
            

There is no need for router

              App.ApplicationRoute      = App.Feature1Route.extend();
              App.ApplicationController = App.Feature1Controller.extend();
              App.ApplicationView       = App.Feature1View.extend();
            

It is not really an application code. You may consider it as configuration. Each single page that needs more advanced JS can have one.

Why all this trouble?

  1. Nice encapsulation
  2. Unit test coverage
  3. Reusable code
  4. Simple path to integrate multiple pages into one app

See you next month at WarsawJS

Fork me on Github