Coder Social home page Coder Social logo

ember-layout's Introduction

This library has been deprecated. Please read this blog post.

Ember Layout

Provides an intuitive layout mechanism for Ember.js. The core addition is a {{dynamicView}} handlebars helper which allows for child views to be dynamically swapped out from anywhere in the template.

How It Works

The {{dynamicView}} binds itself to the content property of its containing view. When the content property is set to a subclass of Ember.View, the dynamic view helper's contents will be replaced to reflect the new view. This property can be changed at any time. To use a different property, simply specify it as follows: {{dynamicView propertyName}}.

Example Layout

Code for the view:

App.layout = Ember.View.create({
  templateName: 'main-layout'
});

Associated template:

<section>
  <header>
    {{dynamicView header}}
  </header>
  
  <div id="content">
    {{dynamicView}}
  </div>
</section>

The {{dynamicView}} regions of the view can now be dynamically populated in code:

App.headerView = Ember.View.create( ... );
App.layout.set('header', headerView);

In fact, swapping out the view in this example is as simple as setting the header or content properties of the view. The content property is the default name of the property bound by {{dynamicView}} if none is specified.

Layout States

Ember.Layout also integrates with Ember's StateManager (and consequently plays well with Ember.RouteManager):

App.stateManager = Ember.StateManager.create({
  rootView: App.layout,
  section1: Ember.LayoutState.create({
    viewClass: App.Section1
  }),
  section2: Ember.LayoutState.create({
    viewClass: App.Section2
  })
})

App.stateManager.goToState('section1');

ember-layout's People

Contributors

ghempton avatar nickurban avatar rlivsey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ember-layout's Issues

unhandled event error if using Ember.data

Discovered that when ember-layout + ember-routemanager are combined with ember-data, you get a 'setData' event being dispatched by the RESTadapter that seems to hit one of the RouteManagers LayoutStates. This causes an error.

The particular event is occuring because in the enter() function for the state, I'm calling find on the datastore, which returns the model record it has immediately, and then dispatches an ajax request for updated information, which triggers a callback when it comes back.

Unfortunately I don't have a simple demo available of the problem, but let me know if you need more to go on, or can see why this is happening

Layout Nesting doesn't work with Ember-0.9.8.1

Hi guys,

Ember
Version: v0.9.8.1-460-gbbd45da

The problem is, if we see on example (http://ghempton.github.com/ember-layout-example/) code:

<script type="text/x-handlebars" data-template-name="section">
  <section>
    <h1>{{title}}</h1>
    {{lorem type=paragraph amount=4}}
  </section>
</script>

The view tags like {{title}} display parentView fields (in example case it's will main layout, but should be ``section`)

// The top level layout
App.main = Em.View.create({
  templateName: 'main'
});

It's easy to test, just add ``{{templateName}}into children view and you will see

main

` when you click on any `sections` links:

<script type="text/x-handlebars" data-template-name="section">
  <section>
    <h1>{{title}}</h1>
    <h2>{{templateName}}</h2>
    {{lorem type=paragraph amount=4}}
  </section>
</script>

Do you have any ideas how to fix it? =)
Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.