Add a function to a Ti.UI.Window

You must Login before you can answer or comment on any questions.

I'm trying to add a function to a window, the code looks like this:

function newWindow () {
  var result = Ti.UI.createWindow({/* args */});
  var private = "Muahaha, you can't overwrite this one.";
  result.getPrivate = function () {
    return private;
  return result;
The problem is that calling win.getPrivate.toString() returns [object TiUIWindow] instead of the code of the function.

win.getPrivate().substr(0,1) raises an exception: 'win.getPrivate()' [null] is not an object.

Adding a method works for Ti.UI.WebView, but not for Window or TabGroup. Do you know any workarounds.

2 Answers

Accepted Answer

You can't add function to UI objects which start by get or set.

Try rename your function

Your Answer

Think you can help? Login to answer this question!