Skip to content

Instantly share code, notes, and snippets.

@jtaby
Created April 11, 2010 21:14
Show Gist options
  • Save jtaby/363070 to your computer and use it in GitHub Desktop.
Save jtaby/363070 to your computer and use it in GitHub Desktop.
NPR.ArticleListItem = SC.View.extend({
content: null,
displayProperties: 'content'.w(),
render: function(context,firstTime) {
context.push("HERE!!");
return sc_super();
}
});
NPR.ArticleList = SC.View.extend(
/** @scope NPR.ArticleList.prototype */ {
// TODO: Add your own code here.
// content:null,
// contentBindingDefault: SC.Binding.multiple(),
contentObserver: function(){
var content = this.get('content');
console.log("content has changed to: "+content.length());
var len = content.length();
var height = this.get('rowHeight');
var width = this.get('columnWidth');
for (var i=0; i < len; i++) {
var view = SC.ListItemView.create({
content:content.objectAt(i),
layout: {
height: height,
width: width,
top: 0,
left: width * i
}
});
this.appendChild(view);
}
var frame = this.get('frame');
frame.width = len * width;
console.log("len * width = "+len * width);
console.log("frame.width = "+frame.width);
// this.set('frame',frame);
// this.notifyPropertyChange('frame');
this.adjust('width',len * width);
}.observes('*content.[]')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment