Git Product home page Git Product logo

Comments (10)

craftpip avatar craftpip commented on August 18, 2024

Hey @sourabhtiwari ,
Can you tell me steps to replicate the problem?

Thanks.

from jquery-confirm.

sourabhtiwari avatar sourabhtiwari commented on August 18, 2024

I HAVE A SUBMIT BUTTON ON MY FORM.

AND ON SUBMIT BUTTON CLICK I HAVE CALLED A FUNCTION WHICH EXECUTES Confirm Box

function validate_save() {
$.confirm({
title: 'Confirm!',
content: 'Are You Sure',
confirm: function () {
return true;
},
cancel: function () {
return false;
}
});
}

from jquery-confirm.

craftpip avatar craftpip commented on August 18, 2024

Apparently, i can guess, you're doing something like this, where you need to prevent the form's submit action.

$('#yourform').submit(function(e){
    e.preventDefault() // Will prevent the page from submit, all you need.
    validate_save(); // your function to show the modal.
})

I hope it helps.

from jquery-confirm.

sourabhtiwari avatar sourabhtiwari commented on August 18, 2024

No I want to Submit form but after confirmation.
e.PreventDefault will prevent form submission and than i will be needed to submit data manually by ajax post.

I want to post data directly from form.but after confirmation...

from jquery-confirm.

craftpip avatar craftpip commented on August 18, 2024

Alright,
The problem here is, $.alert works asynchronously, so it wont wait until the user does any confirmation.
A right way to do it is,

var shouldPrevent = true;
$('#yourform').submit(function(e){
    if(shouldPrevent){
        e.preventDefault();
        $.confirm({
            confirm: function(){
                shouldPrevent = false; // if yes, set to false, 
                $('#yourform').submit(); // and submit the form again.
            }
        })
    }
})

from jquery-confirm.

sourabhtiwari avatar sourabhtiwari commented on August 18, 2024

THANKS A TON @craftpip ...ITS working....

from jquery-confirm.

craftpip avatar craftpip commented on August 18, 2024

Have a great day...
do star jquery-confirm & share it.

from jquery-confirm.

shamnex avatar shamnex commented on August 18, 2024

Having the same issues, it code above works but I still have to press submit again before it gets submitted :(

from jquery-confirm.

craftpip avatar craftpip commented on August 18, 2024

@shamnex , please share your code

from jquery-confirm.

Bich87 avatar Bich87 commented on August 18, 2024

Hi,
please help me! It doesn't work to confirm a submit delete.
When I press "Elimina(delete)", the button close the dialog box but nothing happens.
My code is:

file.php
I have
form id="deletekit"
button id="delete_kitid" type="submit"

file.js
$("#delete_kitid").confirm({
title: "Eliminazione Kit",
content: "Sei sicuro di voler eliminare il kit?",
buttons: {
confirm: {
text: "Elimina",
btnClass: 'btn-danger',
action: function(){
$('#deletekit').submit();
}
},
cancel: {
text: "Annulla",
btnClass: 'btn-default'
}
}
});

Thanks

from jquery-confirm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.