This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/views/container_view.js
2013-06-06 16:48:15 -04:00

38 lines
1.1 KiB
JavaScript

/**
Our own containerView with a helper method for attaching views
@class ContainerView
@extends Ember.ContainerView
@namespace Discourse
@uses Discourse.Presence
@module Discourse
**/
Discourse.ContainerView = Ember.ContainerView.extend(Discourse.Presence, {
/**
Attaches a view and wires up the container properly
@method attachViewWithArgs
@param {Object} viewArgs The arguments to pass when creating the view
@param {Class} klass The view class we want to create
@return {Ember.View} the view we created
**/
attachViewWithArgs: function(viewArgs, viewClass) {
if (!viewClass) { viewClass = Ember.View.extend(); }
var view = this.createChildView(viewClass, viewArgs);
this.pushObject(view);
return view;
},
/**
Attaches a view with no arguments and wires up the container properly
@method attachViewClass
@param {Class} klass The view class we want to create
@return {Ember.View} the view we created
**/
attachViewClass: function(viewClass) {
this.attachViewWithArgs(null, viewClass);
}
});