mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-14 15:41:10 +00:00
Modal form is working for 'create new category'
- Had to set form.helper.form_tag to False (so we could control form tags manually) - Created a 'json' model view
This commit is contained in:
@@ -38,21 +38,42 @@
|
||||
{% block javascript %}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$(document).ready(function () {
|
||||
|
||||
$(".js-create-cat").click(function () {
|
||||
$.ajax({
|
||||
url: '/part/category/new/',
|
||||
type: 'get',
|
||||
//dataType: 'json',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
$("#modal-cat").modal("show");
|
||||
},
|
||||
success: function (data) {
|
||||
$("#modal-cat .modal-content").html(data);
|
||||
//alert(data);
|
||||
$("#modal-cat .modal-content").html(data.html_form);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#modal-cat").on("submit", ".js-modal-form", function () {
|
||||
var form = $(this);
|
||||
|
||||
$.ajax({
|
||||
url: form.attr('action'),
|
||||
data: form.serialize(),
|
||||
type: form.attr('method'),
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data.form_valid) {
|
||||
alert("Success!");
|
||||
}
|
||||
else {
|
||||
$("#modal-cat .modal-content").html(data.html_form);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user