Open a secondary modal over the top of a primary one

This commit is contained in:
Oliver Walters 2019-05-14 22:37:45 +10:00
parent dc3abec899
commit 226644e59a
2 changed files with 22 additions and 6 deletions

View File

@ -385,10 +385,24 @@ function attachSecondaryModal(modal, options) {
* field: Name of the field to attach to * field: Name of the field to attach to
* label: Button text * label: Button text
* title: Hover text to display over button (optional) * title: Hover text to display over button (optional)
* url: URL for the secondary modal
* query: Query params for the secondary modal
*/ */
// Insert the button // Insert the button
insertNewItemButton(modal, options); insertNewItemButton(modal, options);
// Add a callback to the button
$(modal).find("#btn-new-" + options.field).on('click', function() {
// Launch the secondary modal
launchModalForm(
options.url,
{
modal: '#modal-form-secondary',
}
);
});
} }

View File

@ -128,17 +128,19 @@
attachSecondaryModal(modal, attachSecondaryModal(modal,
{ {
'field': 'part', field: 'part',
'label': 'New Part', label: 'New Part',
'title': 'Create New Part', title: 'Create New Part',
url: "{% url 'part-create' %}",
} }
); );
attachSecondaryModal(modal, attachSecondaryModal(modal,
{ {
'field': 'location', field: 'location',
'label': 'New Location', label: 'New Location',
'title': 'Create New Location' title: 'Create New Location',
url: "{% url 'stock-location-create' %}",
} }
); );
} }