user3196424
user3196424

Reputation: 537

Confirm before sort Jquery ui

I want to ask the user to confirm if he really wants to sort the list here is my code

<script language="javascript">
$(document).ready(function () {
    $("#menu-pages").sortable({
        update: function (event, ui) {
            var didConfirm = confirm("Are you sure you want to Update the Navigation?");
            if (didConfirm == true) {
                $.post("ajax.php", {
                    type: "orderPages",
                    pages: $('#menupages').sortable('serialize')
                });
            }
        }
    });
});
</script>

Yes it doesnt send the ajax script but it dont go back to its original position.

Upvotes: 0

Views: 237

Answers (1)

Salman Arshad
Salman Arshad

Reputation: 272066

You can call event.preventDefault() inside the update callback to revert item to its original position.

Demo here

Upvotes: 1

Related Questions