Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop a Bootstrap x-editable from updating an edited field when ajax call fails?

How do I stop a Bootstrap x-editable from updating an edited field when ajax call fails?

I am passing a function as the url.

$('.order-price').editable({
    type: "text",
    title: "Order Price",
    url: function (params) {
        var orderID = $(this).data("order-id");
        var data = "OrderID=" + orderID + "&Price=" + params.value;

        $.ajax({
            type: 'post',
            url: '/Trades/SetOrderPrice',
            data: data,
            async: false,
            error: function (xhr, ajaxOptions, thrownError) {
                return false;
                // Do I return something here instead of false?

            }

        })
    }
});
like image 708
Mike U Avatar asked May 24 '13 23:05

Mike U


1 Answers

You have two options, either throw exception in the callback and x-editable will catch it itself or you can use the "success" event and return an empty string in the success function and you're set

like image 172
Sam Najian Avatar answered Sep 18 '22 10:09

Sam Najian