Skip to content

Instantly share code, notes, and snippets.

@ttdonovan
Created October 3, 2008 20:19
Show Gist options
  • Select an option

  • Save ttdonovan/14633 to your computer and use it in GitHub Desktop.

Select an option

Save ttdonovan/14633 to your computer and use it in GitHub Desktop.
CDFleet.applicationController = SC.Object.create(
/** @scope CDFleet.applicationController */ {
startup: function () {
var main_menu = CDFleet.CDMainMenu.find('Main Menu'); // get object model data
var buttons = main_menu.get('buttons');
CDFleet.mainMenuController.set('content', buttons); // update content of main menu array controller
console.log(CDFleet.mainMenuController.toString(), CDFleet.mainMenuController.get('length')); // length is 10
SC.page.get('contentView').set('content', SC.page.get('desktopView'));
}
}) ;
// ==========================================================================
// CDFleet.CDMainMenu
// ==========================================================================
require('core');
/** @class
(Document your class here)
@extends SC.Record
@author AuthorName
@version 0.1
*/
CDFleet.CDMainMenu = SC.Record.extend(
/** @scope CDFleet.CDMainMenu.prototype */ {
dataSource: CDFleet.server,
properties: ['name', 'children'],
buttons: function () {
return this.get('children').toArray();
}.property('children')
}) ;
CDFleet.CDMainMenuView = SC.View.extend(
/** @scope CDFleet.CDMainMenuView.prototype */ {
emptyElement: '<div></div>',
// Properties
content: [],
contentBindingDefault: SC.Binding.MultipleNotEmpty,
render: function() {
var html = [];
var content = this.get('content');
console.log(content.toString(), content.get('length')); // length is 0
// Iterate through the collection and add buttons
// html.push(this._renderPopupButtonHtml(content));
this.set('innerHTML', html);
}.observes('content'),
_renderPopupButtonHtml: function (content) {
var html = [];
console.log('CDMainMenuView', content.length());
return html.join('');
}
}) ;
<% view :desktop_view do %>
<% view :header, :class => 'sc-header sc-square-theme' do %>
<%= view :main_menu_view, :view => 'CDFleet.CDMainMenuView', :bind => { :content => 'CDFleet.mainMenuController.arrangedObjects' } %>
<% end %> <!-- header -->
<% view :workspace, :class => 'sc-app-workspace header' do %>
<% end %> <!-- workspace -->
<% view :footer, :class => 'sc-footer sc-square-theme' do %>
<% end %> <!-- footer -->
<% end %>
CDFleet.mainMenuController = SC.ArrayController.create(
/** @scope CDFleet.mainMenuController */ {
// TODO: Add your own code here.
}) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment