我正在使用Knockout.JS来驱动表单,并且有一个按钮,当按下该按钮时会显示一个确认窗口.仅在适用于iPhone的Safari中,它始终返回false.它可以在iPhone上与Chrome一起使用,在iPad和笔记本电脑上也可以在所有浏览器(包括Safari)上使用.也没有错误.
I'm using Knockout.JS to power a form and I have a button that when pressed displays a confirmation window. Only on Safari for iPhone it always returns false. It works with Chrome on my iPhone, and on my iPad and laptop it works on all browsers(including Safari). There are no errors either.
self.submitPayment = function(){ var errors2 = ko.validation.group(secondValidationGroup); if (errors2().length == 0) { if(confirm_reservation() == true){ finalizePayment(); //calls function which displays a new div } else{ alert('False was returned'); //displays before I even make a selection } } else{ errors2.showAllMessages(); } } //used to confirm submission for submitPayment function confirm_reservation(){ var conf = confirm('Click OK to submit your payment'); return conf; }在进行选择之前,我会收到返回了错误"的警报.因此,基本上,它甚至不能让我在返回值之前进行选择.
Before I even make a selection, I get the 'False was returned' alert. So basically it's not even letting me make a selection before it returns the value.
编辑-现在可以使用了,我想我可能遇到了错误
我清除了手机上的cookie/缓存,然后将其重新启动,然后它可以正常工作.
I cleared my cookies/cache on my phone and restarted it and then it proceeded to work properly.
推荐答案我认为由于asycnhronus的问题,您的"confirm_reservation"方法不会等待确认结果,而是直接返回false.和你一起.
I think the problem due the asycnhronus things, your "confirm_reservation" method doesnot wait the confirm result, and return false directly.. Can you try below confirm block changing with yours.
confirm('Click OK to submit your payment', function(result) { if(result) { finalizePayment(); } else { alert('False was returned'); //displays before I even make a selection } });更多推荐
JavaScript确认窗口在iPhone的Safari上始终返回false
发布评论