Skip to content

Instantly share code, notes, and snippets.

@iskugor
Created March 20, 2012 08:24
Show Gist options
  • Save iskugor/2132818 to your computer and use it in GitHub Desktop.
Save iskugor/2132818 to your computer and use it in GitHub Desktop.
ZenTi demo - extending TableView
// ZenTi makes doing things like this: http://developer.appcelerator.com/question/134097/commonjs-methodology-how-to-access-inner-object-functions
// easy and intuitive task
// skipped "require" part ...
function TableViews(){
}
extend(TableViews, TableView);
TableViews.prototype.createMyRows = function(data){
var rows =[];
for(var i=0; i<data.length; i++){
rows.push(new TableViewRow(data[i]);
}
return rows;
};
TableViews.prototype.update = function(rowsData){
var rows = this.createMyRows(rowsData);
this.appendRows(rows);
};
module.exports = TableViews;
//somewhere
//no worry about creating instance of Titanium's TableView
var myTableView = new TableViews(); //typeof - [object Object]
myTableView.hasOwnProperty('update'); //true
myTableView.hasOwnProperty('appendRows'); //false
myTableView.upadate(...);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment