Jump to content

How to close pw-modal ?


suntrop
 Share

Recommended Posts

In a custom process module I open a modal window containing a <form>. When I click the submit button, the modal stays open. I can't find a way, other the X from the title bar, to close the modal window.

- How can close the modal, when the submit button was hit?
- Or, how can I implement the buttonpane with the Save button like the PageTable module?
- Or, at least, how can I include my own close button?

That's how I open the modal:

$field = wire('modules')->get('InputfieldButton');
$field->attr('id+name', 'status_update');
$field->attr('class', 'pw-modal pw-modal-small ui-button ui-widget ui-corner-all head_button_clone ui-state-default');
$field->attr('value', 'Update');
$field->attr('data-href', './status-update/?id=' . $op->id);
$form->add($field);

That's my save button

$submit = $modules->get('InputfieldSubmit');
$submit->attr('data-close', 'close');
$submit->attr('value', 'Save');
$submit->attr('name', 'submit_dashboard_status_action');
$form->add($submit);
Link to comment
Share on other sites

You need to set additional data attributes on your button

data-buttons='button#submit_dashboard_status_action' data-autoclose
$field->attr('data-buttons', 'button#submit_dashboard_status_action');
$field->attr('data-autoclose', '');

and your submit button needs an id, too

$submit->attr('id+name', 'submit_dashboard_status_action'); // set id and name in one go

This is documented at the top of file wire/modules/Jquery/JqueryUI/modal.js.

 

  • Like 3
Link to comment
Share on other sites

Thanks for the link. Had not found the source. It seems the 'data-close' button will only listen for clicks if it is defined in 'data-buttons' as well. But all buttons living there will get the same design. Not that good, when Save and Cancel look the same, but it will work for now.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...