Php 单击返回确认在Jquery Mobile中不工作?

Php 单击返回确认在Jquery Mobile中不工作?,php,javascript,jquery,html,jquery-mobile,Php,Javascript,Jquery,Html,Jquery Mobile,我使用的是简单的javascript确认代码: function test_confirm (str) { str = (str == '0')? 'Are you sure?' : str return (confirm(str))? true : false } 这通常有效,除非我使用Jquery Mobile时,OK和Cancel按钮都指向URL。预期的行为是Cancel按钮不应转到URL i、 例如,我通过在html标题中添加以下内容来使用Jquery Mobile

我使用的是简单的javascript确认代码:

function test_confirm (str)
{
    str = (str == '0')? 'Are you sure?' : str

    return (confirm(str))? true : false
}

这通常有效,除非我使用Jquery Mobile时,
OK
Cancel
按钮都指向URL。预期的行为是
Cancel
按钮不应转到URL

i、 例如,我通过在html
标题中添加以下内容来使用Jquery Mobile:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
如您所见,单击URL
list/delete/1
后,删除过程将继续,然后重定向回
list
页面。这就是它开始不起作用的地方


一旦重定向发生,确认对话框就不再工作。

类似的操作对您有用吗

JS

HTML


像这样的东西对你有用吗

JS

HTML


我也遇到了同样的问题,看起来像“return false;”没有停止传播,链接仍然被跟踪。通过在返回false之前显式停止传播来解决此问题

function test_confirm (e, str)
{
    str = (str == '0')? 'Are you sure?' : str

    if (!confirm(str)) {            
        e.stopPropagation();
        return false;
    }
    return true;
}


<a href="http://example.com" onclick="var e=arguments[0] || window.event; return test_confirm(e,0)">Test</a>
功能测试\u确认(e、str)
{
str=(str='0')?“你确定吗?”:str
如果(!confirm(str)){
e、 停止传播();
返回false;
}
返回true;
}

我也遇到了同样的问题,看起来像“return false;”没有停止传播,链接仍然被跟踪。通过在返回false之前显式停止传播来解决此问题

function test_confirm (e, str)
{
    str = (str == '0')? 'Are you sure?' : str

    if (!confirm(str)) {            
        e.stopPropagation();
        return false;
    }
    return true;
}


<a href="http://example.com" onclick="var e=arguments[0] || window.event; return test_confirm(e,0)">Test</a>
功能测试\u确认(e、str)
{
str=(str='0')?“你确定吗?”:str
如果(!confirm(str)){
e、 停止传播();
返回false;
}
返回true;
}
添加此属性

数据ajax=“false”


添加此属性

数据ajax=“false”



我试过了。它仅对锚定标记的第一个实例有效。如果您有许多
,只有第一次单击才有效。我再次尝试禁用Jquery Mobile,一切正常。所以我猜Jquery Mobile.works对我来说有点奇怪:或者你是说在重定向后单击ok/yes/confirm它就不工作了?因为这是一个不同的问题,所以它在基本的例子中起作用。我更新了我的问题来解释发生在我身上的事情。我认为这与rest和重定向有关。我会接受它,因为它可以工作,即使我的情况需要不同的解决方案。我尝试过它。它仅对锚定标记的第一个实例有效。如果您有许多
,只有第一次单击才有效。我再次尝试禁用Jquery Mobile,一切正常。所以我猜Jquery Mobile.works对我来说有点奇怪:或者你是说在重定向后单击ok/yes/confirm它就不工作了?因为这是一个不同的问题,所以它在基本的例子中起作用。我更新了我的问题来解释发生在我身上的事情。我认为这与rest和重定向有关。我会接受这一点,因为它可以工作,即使我的情况需要不同的解决方案
<a href="http://jsfiddle.net/8CDc5/" class="customClick" data-str="0">Test</a>​
function test_confirm (e, str)
{
    str = (str == '0')? 'Are you sure?' : str

    if (!confirm(str)) {            
        e.stopPropagation();
        return false;
    }
    return true;
}


<a href="http://example.com" onclick="var e=arguments[0] || window.event; return test_confirm(e,0)">Test</a>
<a data-ajax="false" href="http://example.com" onclick="return test_confirm(0)">Test</a>