Skip to content

Instantly share code, notes, and snippets.

@topherfangio
Created March 6, 2011 14:56
Show Gist options
  • Save topherfangio/857345 to your computer and use it in GitHub Desktop.
Save topherfangio/857345 to your computer and use it in GitHub Desktop.
Incorrect but Working Binding
Pharos360.labelsController = SC.ArrayController.create(
/** @scope Pharos360.labels.prototype */ {
// TODO: Add your own code here.
}) ;
/*
* This is the portion of the Ki state that sets up the labels' store.
*/
enterState: function() {
/*
* Normally we'd start talking to the server and setup a callback that would
* fire when the data was received (or we'd observe the datastore and wait for the
* data to be available). Since this is just a fixtures DataStore...we won't worry
* about that currently.
*/
var coursesStore = Pharos360.store.find(Pharos360.Course);
var labelsStore = Pharos360.store.find(Pharos360.Label);
if (coursesStore != null && labelsStore != null) {
// Setup the controllers
Pharos360.coursesController.set('content', coursesStore);
Pharos360.labelsController.set('content', labelsStore);
// Show the UI
Pharos360.getPath('mainPage.mainPane').append();
} else {
console.log('An error occured while attempting to load the course/label information.');
}
},
Pharos360.NavigationView = SC.ScrollView.extend(SC.ContentDisplay, {
testVar: "something",
displayProperties: ['myTest'],
myTestBinding: 'Pharos360.labelsController.arrangedObjects.length',
// DOESN'T WORK: myTestBinding: 'Pharos360.labelsController.arrangedObjects',
render: function(context) {
sc_super();
console.log('render called');
var data = { sc_view:this };
var template = SC.TEMPLATES['navigation'];
context.push(template(data));
},
update: function(jquery) {
console.log('event fired...');
var labels_html = "";
Pharos360.labelsController.forEach(function (label, index) {
labels_html += "<li class='label'>" + label.get('title') + "</li>";
});
jquery.find('ul.labels').html(labels_html);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment