Daniel Pineault
asked on
Reopen modal buttons no longer work?
I'm struggling to close a modal window and then reopen it.
Upon submitting a modal I use
Now, although not the way I wanted to handle this, it does work in a general sense. It closes the 2 modal windows and then reopens the second one displaying the submission. The issue I'm facing is that if I close the modal and then reopen it, none of the buttons works. They all loose their event and I don't get why?
I've been at this for 2 days and just can't figure it out. I've tried all sorts of things.
Thank you in advance.
Upon submitting a modal I use
$('form#{$model->formName()}').on('beforeSubmit', function(e){
var \$form = $(this);
$.post(
\$form.attr("action"), //serialize Yii2 form
\$form.serialize()
)
.done(function(result){
//console.log(result);
result = JSON.parse(result);
if(result.status == 'Success'){
$(\$form).trigger("reset");
// $.pjax.reload({container:'#InvoiceItemsListGrid'}); //Does not work and reloads the main page, not the modal window?!
$("#closeButton3").click(); //Close the 3rd modal
$("#closeButton2").click(); //Close the 2nd modal
$("#"+$('#modalPopup2 #passInfo #refBtn').val()).click(); //re-open the 2nd modal by clicking on the appro button to refresh the info
}else{
$(\$form).trigger("reset");
$("#message").html(result.message);
}
})
.fail(function(){
console.log("server error");
});
return false;
});
Now, although not the way I wanted to handle this, it does work in a general sense. It closes the 2 modal windows and then reopens the second one displaying the submission. The issue I'm facing is that if I close the modal and then reopen it, none of the buttons works. They all loose their event and I don't get why?
I've been at this for 2 days and just can't figure it out. I've tried all sorts of things.
Thank you in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome sir, glad we could help.
ASKER
I was doing
Open in new window
I thought the above did the same thing, but obviously not as by using
Open in new window
works perfectly.