Change tabs from within webview
Hi there,
I'm just coming from jQTouch, and am attempting to recreate my app in titanium using webviews (just to start whilst I get to grips with the software).
I'm working with the kitchen sink at the moment, and have been able to get my webviews setup with tabs, but wondered:
How can I change tabs from within the webview html?
ie. I've split my app into 4 html pages (across 4 tabs). Some of these pages have html buttons (a href) in them. Is there an onclick action or something I can use to click one of these buttons in the webview html that will change the tab in titanium?
My tab items are setup as so:
var win1 = Titanium.UI.createWindow();
var tab1 = Titanium.UI.createTab({
icon:'images/tabs/card1.png',
title:'Card 1',
window:win1
});
var webview1 = Titanium.UI.createWebView({url: 'index.html'});
win1.add(webview1);
win1.hideNavBar();
1 Answer
-
Hi again,
I've been through these threads for hours, and think i've got the general gist of it (customising some existing code). Would someone know if this is the correct way of doing things?Thanks!
GlenIN APP.JS
Ti.App.addEventListener('gotoCard3', function() { tabGroup.setActiveTab(2); });
IN HTML
<a href="#" class="btn" onClick="Ti.App.fireEvent('gotoCard3');">Card 3 Link</a>