Refresh Page upon tab click

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

Hi All

I am looking for a way to reload a page upon a tab click currently it just maintains the previous state i want it to completely close and reopen again.

I am a newbie at titanium so some help with this would be amazing.

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
var tabGroup = Titanium.UI.createTabGroup();
var musicPlayer = Titanium.UI.createWindow({
    title:'Music Player',
var MusicPlayerTab = Titanium.UI.createTab({
    title:"Music Player",
var musicSync = Titanium.UI.createWindow({
var musicSyncTab = Titanium.UI.createTab({
and player.js i have been trying to do the following but it doesnt work.
var win = Titanium.UI.currentWindow;
Ti.UI.currentWindow.addEventListener('open', function(e) {
//code runs here???
so i am looking for every time the MusicPlayerTab is open it re runs the code from scratch instead off maintaining previous state.

1 Answer

Accepted Answer

try using the focus event or blur event

Ti.UI.currentWindow.addEventListener('focus', function(e) {
//code runs here???
Ti.UI.currentWindow.addEventListener('blur', function(e) {
//code runs here???

— answered 3 years ago by Arian Caraballo
answer permalink
  • you sir are a legend thanks for the prompt response sorted focus works for me.

    — commented 3 years ago by samuel east

  • it seems that, in my project, the focus event is fired multiple (2) times when the tab is clicked. And the blur and focus events seem to fire when screen on/ off. So it's not the same.

    — commented 2 years ago by han woolderink

Your Answer

Think you can help? Login to answer this question!