Note that there are some explanatory texts on larger screens.

plurals
  1. POadd Event Listener to button Titanium, link to window
    text
    copied!<p>I am trying to make a button that when clicked, goes to a window. I have already created the window and also created its own .js file. I cannot get the button to work, any suggestions on where I am going wrong? Here is my code:</p> <pre><code>var platformWidth = Titanium.Platform.displayCaps.platformWidth; var platformHeight = Titanium.Platform.displayCaps.platformHeight; var win = Titanium.UI.currentWindow; var playButton = Titanium.UI.createButton({ title: "Play", style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED, center: { x: platformWidth * 0.5, y: platformHeight * 0.5 } }); win.add(playButton); playButton.addEventListener('click' , function() { playButton.url='playWindow.js' }); </code></pre> <p>I know that the playWindow.js works as I have tabs working on the pages that are linked.</p> <p>playWindow.js</p> <pre><code>var platformWidth = Titanium.Platform.displayCaps.platformWidth; var platformHeight = Titanium.Platform.displayCaps.platformHeight; var win = Titanium.UI.currentWindow; var testTextField = Titanium.UI.createTextField({ backgroundColor: 'white', borderStyle: Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, center: { x: platformWidth * 0.5, y: platformHeight * 0.3 }, width: platformWidth * 1 }); win.add(testTextField); </code></pre> <p>I am wondering whether having the different windows as different files is a good idea. They don't seem to be working correctly. How come there isn't a simple code for buttons, like there is for tab (ie: window: 'playWindow')?</p> <p>I got a -1 for my question saying it doesn't show any research effort. I have spent the last 4-5 hours trying to find a solution to something so simple.. maybe it is too simple. All I want to be able to do is have a button on one page, that when clicked, goes to another... </p> <p>TIA Ange</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload