Skip to content

Instantly share code, notes, and snippets.

@alg
Created June 21, 2012 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alg/2964374 to your computer and use it in GitHub Desktop.
Save alg/2964374 to your computer and use it in GitHub Desktop.
Exposing an interface between windows in Titanium
//error when the a table row is clicked in nearme_window.js
[WARN] Exception in event callback. {
line = 59;
message = "'undefined' is not a function (evaluating 'pub_win.update_pub_details('blah')')";
name = TypeError;
sourceId = 233027648;
}
//nearme_window.js
module.exports = (function() {
var self = this,
pub_win = require('fb/ui/pub_window'),
win = gui.createWindow({
title: L('title_nearme')
}),
nav = Titanium.UI.iPhone.createNavigationGroup({ window: win });
var refresh = function() {
api.getNearbyPubs(function(response_json) {
var table = Ti.UI.createTableView();
createTableData(response_json, table);
table.addEventListener('click', function(e){
pub_win.update_pub_details(e.rowData);
nav.open(pub_win, {animated:true});
});
win.add(table);
});
}
//pub_window.js
var lbl_pub_name = null;
exports.update_pub_details = function(pub_list_row) {
lbl_pub_name.text = pub_list_row.pub_name;
}
module.exports = function() {
lbl_pub_name = Ti.UI.createLabel({
...
return win;
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment