Fire 'tel' link from button in Sencha Touch

≯℡__Kan透↙ 提交于 2020-01-01 03:36:29

问题


I have an ActionSheet which is shown when a user taps on a list item. In the ActionSheet are three buttons - one to remove the contact, one to make a call to them and one to dismiss the ActionSheet. My question is, how do I bind the equivalent of a <a href="tel:000000000"></a> to the button?

I need to specify the 'tel:' protocol so that iOS and Android will force the Phone application to load with this number?


回答1:


It's pretty simple,

All you have to do is change the document's location (window element) in the button's handler:

        var tapHandler = function(button, event){
            Ext.Msg.confirm('External Link', 'Call ' + button.contactName + "?", function(res){
                if (res == 'yes') {
                    window.location = button.callUrl;
                }
            }, this);

        };


        var callButton = new Ext.Button({
            text: 'Call Now',
            callUrl: 'tel:995223423',
            contactName: 'Ben M',
            handler: tapHandler
        });



回答2:


Haven't tried this, but if Rubinsh's method doesn't work try creating it programmatically in the button's click handler.

function(){
   var alink = Ext.getBody().createChild({tag: 'a', href: 'tel:#########'});
   var event = document.createEvent("TouchEvent");
   event.initTouchEvent('tap', true, true, window, 0, 0, 0, 0);
   alink.dispatchEvent(event);
}

References

  • SenchaTouch Source 1.1.0 sencha-touch-debug-w-comments.js:27962
  • Apple Developer Reference for TouchEvent


来源:https://stackoverflow.com/questions/5528290/fire-tel-link-from-button-in-sencha-touch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!