PDA

View Full Version : Make the <href tel:> to work?



ttkrpink
6 Dec 2011, 12:39 PM
Can Sencha Touch 2 make <a href="tel:+18009999999">call me</a> to work? I searched a little bit. To make a phone call through an app, I have to use PhoneGap. Some posts say it's a security reason. If so, can someone explain why phonegap can do it but not sencha touch?

Thanks.

ttk

mitchellsimoens
6 Dec 2011, 1:21 PM
This was because ST2 wasn't allowing it. We are aware of it and will get fixed before final release.

aoathout
6 Dec 2011, 4:09 PM
While href:tel may not be working right now you do have other options. For instance the following is example of what is working for me:


Ext.define('Test.view.Test', {
extend: 'Ext.Panel',
alias: 'widget.test',


config: {
fullscreen: true,
layout: {
type: 'vbox'
}
},


initialize: function() {
var me = this;
me.setItems([
{
xtype: 'panel',
html: '<div>Phone: <span style="text-decoration: underline !important;" class="link" data-link="tel:+18887362421">1 (888) 736-2421</span></div>',
styleHtmlContent: true,
listeners: [
{
event: 'show',
scope: this,
fn: this.onPanelShow
}
]
}
]);
me.callParent(arguments);
},


onPanelShow: function(component, options) {
component.getEl().on({
tap: function(event) {
var location = event.getTarget().getAttribute('data-link');
window.location = location;
},
delegate: '.link'
});
}
});


The important part here is listening for 'tap' on the components element and then using a delegate to specify exactly what item you want to listen for. In this case I'm listening for the tap event on any child elements with a class = 'link'.

Hope this helps