Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

webview links inside tableviewrow not clickable

Trying to write my first iPhone app using Appcelerator from the 2-tab starter project. The 1st tab is a table of items with children detail pages. The detail pages include a description with embedded links to glossary terms. The 2nd tab is the table of glossary terms with detail pages of definitions.

So I tried to embed a webview into a tableviewrow that will link back via fireEvent to switch tabs and navigate to the appropriate glossary term. I am testing using just a simple URL instead of the JS to fireEvent, but clicking on the hyperlink has no effect. Suggestions?

var data = [];
data[0] = Titanium.UI.createTableViewSection({headerTitle:'Definition'});
var defnRow = Titanium.UI.createTableViewRow({
    height:'auto'
});

var defnWebView = Titanium.UI.createWebView({
    html:'<html><body>Description with <a href="http://www.google.com">link</a></body></html>',
    height:'auto'
});
defnRow.add(defnWebView);
data[0].add(defnRow);

var table = Titanium.UI.createTableView({
    data:data,
    style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
    allowsSelection:false,
});
— asked August 13th 2010 by hubert pan
  • iphone
  • mobile
  • tableview
  • webview
0 Comments

1 Answer

  • I wouldn't suggest you to do this. Each webview you are opening will eat a lot of CPU. Why don't you simple use the table click event ?

    And if you want custom rows you may want to take a look at this tutorial:

    http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/

    — answered August 13th 2010 by Dan Tamas
    permalink
    1 Comment
    • Yeah, it seemed like a kludgy way to solve my problem. Essentially, I want the row to have a sentence of text, possibly with a few terms (not the entire row) underlined and linked to an eventListener on click to switch to the glossary.

      The only way I could think of using native components is breaking the sentence into separate Labels for clickable/nonclickable and drawing in underlines. But that seems hard to line up reliably and programmatically, especially since each item will have a different sentence. Is there a better way to do this?

      — commented August 13th 2010 by hubert pan
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.