Skip to content

Instantly share code, notes, and snippets.

@mauritslamers
Created October 9, 2008 10:38
Show Gist options
  • Save mauritslamers/15746 to your computer and use it in GitHub Desktop.
Save mauritslamers/15746 to your computer and use it in GitHub Desktop.
// ==========================================================================
// Admissionexam.CheckBoxListView
// ==========================================================================
require('core');
/** @class
(Document Your View Here)
@extends SC.View
@author AuthorName
@version 0.1
*/
AdmissionExam.CheckBoxListView = SC.CheckboxView.extend(
/** @scope Admissionexam.CheckBoxListView.prototype */ {
_contentObserver: function(){
// read the name from the content and set up the rest
var content = this.get('content');
if(content){
var tmpName = content.get('name');
//console.log(tmpName);
if(tmpName){
this.set('title',tmpName);
// setup other things? not at the moment
}
}
}.observes('content'),
_valueObserver: function(){
var curValue = this.get('value');
var curContent = this.get('content');
var curSelection = this.get('parentNode').get('parentNode').get('selection');
if(curValue){
// add to selection
curSelection.push(curContent);
}
else {
var newSelection = [];
curSelection.each(function(s){
if(s !== curContent){
newSelection.push(s);
}
});
this.get('parentNode').get('parentNode').set('selection',newSelection);
}
//console.log(this.get('parentNode').get('parentNode'));
}.observes('value')
// TODO: Add your own code here.
}) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment