JSFiddle - React, Tailwind, and code Playground
HTML
<form id="tasks">
<input type="hidden" name="some_id" value="34" />
<input type="submit" value="Delete" id="rusure" />
</form>
<div id="dialog">U shur?</div>
JavaScript
$("#dialog").dialog({
modal: true,
bgiframe: true,
width: 500,
height: 200,
autoOpen: false
});
$("#rusure").click(function(e) {
e.preventDefault();
// Create hidden input from button and append to form
var input = $('<input name="confirm_delete" value="yesplz" type="hidden" />').appendTo('#task');
$("#dialog").dialog('option', 'buttons', {
"Confirm" : function() {
//$("#tasks").submit();
alert($('#tasks').serialize());
},
"Cancel" : function() {
$(this).dialog("close");
$(input).remove();// Remove hidden input
}
});
$("#dialog").dialog("open");
});