简体   繁体   English

Django - 如何拨打电话号码并一键打开表单页面?

[英]Django - how to call a phone number AND open a form page with one click?

I hope to get ist straight: I have a Django app with customer addresses and 'activities' whoch protocolls any contact to customers via email or phone.我希望直截了当:我有一个 Django 应用程序,其中包含客户地址和“活动”,通过 email 或电话与客户联系。 When the user clicks on a phone number (link) I want the system to dial that number and at the same time to create a record in a table (activities), render another page with a form, where he writes down notes while talking to the customer.当用户单击电话号码(链接)时,我希望系统拨打该号码,同时在表格(活动)中创建记录,用表格呈现另一个页面,在那里他在交谈时写下笔记客户。

How can I do that without a second click?没有第二次点击我怎么能做到这一点?

I know, I create a link <a href='tel:{{ customer.phone }}'> that much is clear.我知道,我创建了一个链接<a href='tel:{{ customer.phone }}'>很清楚。 But how to do a second action on the same click?但是如何在同一次点击上做第二个动作呢? Probably with JavaScript (I use jQuery, but am a novice to JavaScript).可能使用 JavaScript(我使用 jQuery,但我是 JavaScript 新手)。

Alternatively I thought I could call the "Call-Phone-Number" action in a view which is called by the link (instead of 'tel:...') in the first place and does all the form rendering, which is more comfortable for me.或者,我认为我可以首先在由链接(而不是'tel:...')调用的视图中调用“Call-Phone-Number”操作并执行所有表单呈现,这更舒服为了我。 But how to call a phone number from a view in python and render a page simultaniously (or one after the other without waiting)?但是如何从 python 中的视图中调用电话号码并同时呈现页面(或一个接一个而无需等待)?

I hope my situatuon is clear...我希望我的情况很清楚...

Thanx for any help!感谢您的帮助!

You could try the following JS:您可以尝试以下JS:

window.onload = function(e){
            window.location.href = your_url
            return false;
        }

This will basically be like the user clicking on that link.这基本上就像用户单击该链接一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM