public
Description: JavaScript Application Framework - JS library only
Home | Edit | New

Container_view

A container_view is a view helper providing a container for all kinds of view. It can be used to have different views appear in one place in the page, for example based on a selection of possiblities.


<%= container_view :name_of_view ,
      :bind => {
          :content => 'MyApp.ObjectController.property'
      }
%>
  • name_of_view :: The name of the view to be used

The content binding of the container view needs to point at a property of an object controller. This property needs to return a SC.View.
The property can be a computed property in case a model is used to keep track of the different views:


   returnView: function(){
     var viewname = this.get('view').dasherize().camelize();
     return SC.page.get(viewname);
   }.property('view')

The views that need to be put in the container_view have to be declared in the rhtml files, but outside the content_for(‘body’) part, in the same way as declaring a pane_view. It is possible to create separate rhtml files for every view.

Comments

Last edited by mauritslamers, Sun Sep 28 09:53:20 -0700 2008
Home | Edit | New
Versions: