Question

Using a javascript confirm on my page but it is being odd.

As per the title, it shows twice in safari, works fine in firefox but doesnt show at all in chrome.

If i put my code into a jsfiddle it has no issues. No im not sure where to go from here. No errors in my console etc.

The code is below, but im not sure its actually related to it. Its the only place where the confirm is called / any actions for the button are. No duplicate ids etc.

Any help? Where to check next possibly? thanks for any help!

Here is a fiddle: http://jsfiddle.net/EEw9P/1/

NOTE: This works on all browsers for some reason.

The code i am using is this:

// 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;
    }

});

});

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top