Yes, you can do that in Titanium.
Created
September 18, 2015 12:47
-
-
Save yomybaby/154a2755cf70bda03dd2 to your computer and use it in GitHub Desktop.
Titanium : AttributedString in ListItem with link event.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var html2as = require('nl.fokkezb.html2as'); | |
function onClickLink(e){ | |
alert(e.url); | |
} | |
var contents = [ | |
'Korean Community <a href="wow">http://tidev.kr</a>', | |
'Yo Studio : <a href="http://yostudio.kr">http://yostudio.kr</a>' | |
]; | |
var items = []; | |
_.each(contents,function(c){ | |
var attStr; | |
html2as(c,function(err, as){ | |
if(!err){ | |
attStr = as; | |
} | |
}); | |
items.push({ | |
template : 'myItem', | |
content : { | |
attributedString : attStr | |
} | |
}) | |
}); | |
$.section.items = items; | |
$.index.open(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<Window class="container"> | |
<ListView> | |
<Templates> | |
<ItemTemplate name="myItem"> | |
<Label class="contentLabel" bindId="content" onLink="onClickLink"></Label> | |
</ItemTemplate> | |
</Templates> | |
<ListSection id="section"> | |
</ListSection> | |
</ListView> | |
<Label/> | |
</Window> | |
</Alloy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment