jasonkneen / ti-html2as

HTML 2 AttributedString converter for Titanium
Other
64 stars 24 forks source link

ti-html2as for ios links are not clickable or not opening in browsers #30

Closed arrk-jeevank closed 8 years ago

arrk-jeevank commented 8 years ago

Hi Fokke,

i am using your ti-html2as(1.2.1) module, it working fine in andriod, but when i have implemented the same for ios then the text is displaying as Hyperlinks but those where not clickable or i can say not opening in safari or chrome browsers. Using simulators and with devices like (iphone 4s and Ipad 2) i have tested it not working.

Thanks & Regards Jeevan K Reddy

arrk-jeevank commented 8 years ago

I am using Titanium sdk 3.5.1, so i had used older version of your module.

FokkeZB commented 8 years ago

Using an older version fixed it?

arrk-jeevank commented 8 years ago

with titanium sdk 3.5.1 + ti.html2as 1.2.1 <a href=""> tag is not working. the below how i have used in IOS

<Label module="xp.ui" html="<font size=17>Hello <a href='http://www.google.com/'>www.google.com</a> world <a href='http://google/'>welcome</a>.</font>" />
FokkeZB commented 8 years ago

In what way is it not working?

arrk-jeevank commented 8 years ago
<Label module="xp.ui" html="<font size=17>Hello <a href='http://www.google.com/'>www.google.com</a> world <a href='http://google/'>welcome</a>.</font>" />
FokkeZB commented 8 years ago

@arrk-jeevank you have to use markdown formatting to insert XML ;)

I mean, what result does that code get you? Do you have a screenshot?

arrk-jeevank commented 8 years ago

<Label module="xp.ui" html="<font size=17>Hello <a href='http://www.google.com/'>www.google.com</a> world <a href='http://google/'>welcome</a>.</font>" />

arrk-jeevank commented 8 years ago

the links are not opening in the browser , it didn't thrown any error , it looks like hyperlink but not opening

FokkeZB commented 8 years ago

You did add a listener to the link event?

arrk-jeevank commented 8 years ago

no , i will try and let you know

FokkeZB commented 8 years ago

That's a requirement ;0 See http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Label-event-link

arrk-jeevank commented 8 years ago

using attributed string i had tried with link event. it didn't work , so i tried to use your module it gives me the same. both didn't work . link event not getting fired

FokkeZB commented 8 years ago

This module also uses Attributed String, it just converts HTML to an Attributed String for you. Could you post a full code sample?

arrk-jeevank commented 8 years ago
var text=“hello goole (www.google.com) world”

var attr = Ti.UI.iOS.createAttributedString({
    text: text,
    attributes: [
        {
            type: Titanium.UI.iOS.ATTRIBUTE_LINK,
            value: "https://github.com/appcelerator/hyperloop",
            range: [text.indexOf('www.google.com), ('www.google.com').length]
        }  ,
        {
            type: Titanium.UI.iOS.ATTRIBUTE_LINK,
            value: "https://google.com",
            range: [text.indexOf(‘world’), (‘world’).length]
        }  
    ]
});
attr.addEventListener('link', function(e){
    Ti.API.info(JSON.stringify(e));
});
FokkeZB commented 8 years ago

You need to add the event listener to the label you add the attributed string to. Please check the api reference I linked above.

arrk-jeevank commented 8 years ago
$.type.addEventListener('link', function(e){
    Ti.API.info(JSON.stringify(e));
});

$.type.attributedString=attr;
Label tag below 
Label id="type"  class="disclamier-text">  Providing this information will help us show you the most appropriate parts of this > app</Label
FokkeZB commented 8 years ago

Closing as I can't reproduce and seems like a Ti bug, if any.