Javascript确认在Safari中显示两次,在Firefox中运行正常但在Chrome中无法显示

时间:2014-02-23 15:43:17

标签: javascript jquery forms google-chrome confirm

在我的页面上使用javascript确认,但它很奇怪。

根据标题,它在safari中显示两次,在firefox中工作正常但在chrome中根本不显示。

如果我将我的代码放入jsfiddle,它没有问题。不,我不知道从哪里去。我的控制台没有错误等。

代码如下,但我不确定它实际上与它有关。它是唯一一个调用确认/按钮的任何动作的地方。没有重复的ids等。

有任何帮助吗?下一步可能在哪里检查?谢谢你的帮助!

这是一个小提琴:http://jsfiddle.net/EEw9P/1/

注意:由于某种原因,这适用于所有浏览器。

我正在使用的代码是:

// if the save button is clicked, add a class to it
$(document).on('click','.saveupdatebutton',function(){
$(this).addClass('activeBtn');
});

// check the form for submit
$(document).ready(function () {
$(document).on('submit','.updatepost',function(){

    // this var checks if the save button has been clicked and had the class added to it
    var isSave = $(this).find('.saveupdatebutton').is('.activeBtn');

    if (isSave) {

        var $targetForm = $(this);

        $targetForm.find(".error").remove();
        $targetForm.find(".success").remove();

        // ... goes after Validation
        if (check) {
            $("#loaderEditPost").show();
            $.ajax({
                type: "POST",
                url: "process/updatepost.php",
                data: $targetForm.serialize(),
                dataType: "json",
                success: function (response) {

                    if (response.databaseSuccess) {
                disableComments();
            } else {
                        $ckEditor.after('<div class="error">Something went wrong!</div>');
        }
                }
            });
        }
        return false;

    } else {

        // check if the user REALLY wants to delete the post
        if (confirm('Confirm deletion of your builds update?')) {

        // DELETE POST!
        var $targetForm = $(this);

        $targetForm.find(".error").remove();
        $targetForm.find(".success").remove();

        // If there is anything wrong with 
        // validation we set the check to false
        var check = true;

        // Get the value of the blog update post
        var $ckEditor = $targetForm.find('.ckeditor'),
            blogpost = $ckEditor.val();

        // ... goes after Validation
        if (check) {
            $.ajax({
                type: "POST",
                url: "process/deletepost.php",
                data: $targetForm.serialize(),
                dataType: "json",
                success: function (response) {

                    if (response.deleteSuccess)
                    $("#container").load("#container");
                    else
                    $ckEditor.after('<div class="error">Something went wrong!</div>');

                }
            });
        }
        return false;
    }
    // if the user doesnt wish to delete their post
    else 
        return false;
    }

});

});

0 个答案:

没有答案