Function to insert a 'create new' button into a form

- Look for a label like <label for="id_<field>">
This commit is contained in:
Oliver Walters 2019-05-14 22:12:22 +10:00
parent 0cc2e71843
commit a96cd2240c
2 changed files with 22 additions and 0 deletions

View File

@ -192,6 +192,16 @@
width: 100%;
}
/* Force a control-label div to be 100% width */
.modal .control-label {
width: 100%;
}
.modal .control-label .btn {
padding-top: 3px;
padding-bottom: 3px;
}
/* The side navigation menu */
.sidenav {
height: 100%; /* 100% Full-height */

View File

@ -354,6 +354,18 @@ function injectModalForm(modal, form_html) {
}
function insertNewItemButton(modal, field, text) {
var html = "<span style='float: right;'>";
html += "<div type='button' class='btn btn-primary' id='btn-new-" + field + "'>" + text + "</div>";
html += "</span>";
$(modal).find('label[for="id_'+ field + '"]').append(html);
}
function handleModalForm(url, options) {
/* Update a modal form after data are received from the server.
* Manages POST requests until the form is successfully submitted.