0

I don't know exactly why this happens, here is some of the code:

function submit_edit(url) {
    var value = $('#clicked').val();
    var staff_ID = $('#staff_id').val();

    if (value == 'Delete') {
        url = url + '/Delete/' + staff_ID;
        alert(url);
        myApp.confirm('Are you sure?', 'Delete Staff', function () {
            check_url(url);
        });
        return false;
    }
    else if (value == 'Submit') {
        alert(url);
        myApp.confirm('Are you sure?', 'Submit Changes', function (event) {
            //event.preventDefault();
            check_url(url);

        });
        return false;
    }
    else if (value == 'Cancel') {
        url = url + '/Cancel';
        myApp.confirm('Are you sure?', 'Cancel Changes', function () {
            check_url(url);
        });
        return false;
    }
}

The delete and cancel statements work. But when I hit submit, it doesn't process the form. Granted the other two don't use any of the checkbox inputs. The script will work as soon as I turn the return false; to return true;, but it will redirect it... which isn't what I want. This is the closest I've gotten so far. You can request extra code if need be, I will supply it. I do appreciate all answers and feedback!

Update


Here is the requested code for the check_url()

    function check_url(recieve_url) {
    if (recieve_url == undefined || recieve_url == null) {
        alert("recieve_url is not set!");
    }
    $.ajax({
        url : recieve_url,
        type : 'POST',
        dataType : 'json',
        success : function (result) {
            //alert(result['bg'] + result['message'] + result['caption'])

            myApp.alert(result['message'], result['title'], function () {
                if (result['redirect'] != null || result['redirect'] != undefined){
                    window.location = "<?php echo $this->url;?>"+result['redirect'];
                }
            });
                //myApp.alert(result['message'], result['title']);


        },
        error : function (xhr, ajaxOptions, thrownError) {
            myApp.alert(xhr.responseText);
            myApp.alert(recieve_url);
            myApp.alert(thrownError);
        }

    })

}
tomirons
  • 554
  • 2
  • 14
  • you can't do the return true AND have a custom confirm dialog. there is no other way than manually submitting the form when you want it submitted. – Kevin B Aug 29 '14 at 19:07
  • Where is the AJAX, in the `check_url()` function? – Barmar Aug 29 '14 at 19:07
  • Maybe have a look at: [How to continue form submission after an AJAX call?](http://stackoverflow.com/q/9331042/218196) – Felix Kling Aug 29 '14 at 19:09
  • Im trying to keep the `return false;` – tomirons Aug 29 '14 at 19:09
  • @Barmar, I added the code to the question. – tomirons Aug 29 '14 at 19:14
  • I don't understand, where do you expect it to process the form? Returning false from an event handler means you don't want the default action to take place, it's the old way of doing `event.preventDefault()`. – Barmar Aug 29 '14 at 19:34
  • I would like to have it submit just like the `delete` one but for some reason it doesn't want to post the variables. – tomirons Aug 29 '14 at 20:43

0 Answers0