PDA

View Full Version : Toolbar button anchor link



dmillasich
14 Mar 2011, 6:13 AM
I'm fairly new to the Sencha Touch API. I'm trying to do something that it's fairly easily accomplished in other Javascript APIs such as JQuery and Mootools, but I'm struggling to get this issue worked out.

I have a panel with several elements, one of which is a bit of text combined with an anchor link, for example:



var myPanel = new Ext.Panel({
id: 'my-panel',
dock: 'top',
cls: 'my-panel',
dockedItems: [{
id: 'my-link',
cls: 'my-link',
dock: 'top',
html: '<a href="http://www.google.com'">Google</a>'
}]
});


I would like to have the functional equivalent of the anchor link attached to a button on a toolbar. In theory, something like this:



var myToolbar = new Ext.Toolbar({
dock: 'top',
items: [{
iconCls: 'my-toolbar',
text: 'Google!',
html: '<a href="http://www.google.com">Google</a>'
}]
});


It seems likely to me that there would be a way of navigating away from my Sencha Touch app to an external url specified by a link on a toolbar button.

Thanks in advance for any ideas.

crysfel
14 Mar 2011, 10:09 AM
How about this:



var myToolbar = new Ext.Toolbar({
dock: 'top',
items: [{
iconCls: 'my-toolbar',
text: 'Google!',
handler : function(){
document.location = "http://www.google.com";
}
}]
});


Good luck

dmillasich
14 Mar 2011, 11:27 AM
Hello crysfel -

...actually - sort of.

Some things about my app complicate the provided solution:


The app is actually linking to a netflix.com url.
The app is meant to be run from an iPad.
The app is instantiated from an icon on the iPad "home screen".


This works just fine as long as the app is not started from the "home screen".

If I run the application by going to it in Safari - the "document.location = "http://www.netflix.com/WiPlayer?movieid=123456789" solution works. From the "home screen" however, I get a funky error message from the target server. The target url renders up to a point - then presents an alert message that it "Cannot open [home screen icon name here]".

These are all details I should have provided in the beginning. Sorry about that. It was well before my daily allotment of coffee.

Ashulove
18 May 2012, 1:41 AM
how to add link button in grid column.

mer34
10 Jul 2014, 3:33 AM
thaks