Bexazak
12/6/2017 - 11:28 AM

x-editable with sweetalert

            function confirmationEditabl(id, saveId) {
                var newValue = $('#' + id).closest('.field_editable').find('.editableform textarea').val();
                $('#' + id).editable('setValue', newValue);
                $('#' + saveId).val(newValue);
            }

            $('body').on('click', '.editable-submit', function (e) {
                e.preventDefault();
                var thisIdGetValue = $(this).closest('.field_editable').find('.editable_link').attr('id');
                var idPutValue = $(this).closest('.field_editable').find('.hidden_forEditable').attr('id');
                swal({
                    title: "Are you sure?",
                    type: "error",
                    showCancelButton: true,
                    confirmButtonClass: 'btn-danger waves-effect waves-light',
                    confirmButtonText: 'Yes, I am sure'
                }, function (isConfirm) {
                    if (isConfirm) {
                        confirmationEditabl(thisIdGetValue, idPutValue);
                    }
                });
            });

            $('.field_editable:not(.readonly) #inline-pubkey').editable({
                type: 'text',
                pk: 1,
                name: 'pubkey',
                title: 'Enter public key',
                mode: 'inline'
            });