You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Edit form.twig add the data-code attribute like this data-code=""
it should look like <form action="{{ page.url }}" method="POST" id="code-edit-form">
create populate_edit_from_button(button, modal) function
NOTE:: EDIT so it applies to the code table so it populates the right fields
function populate_edit_from_button(button, modal) {
var code = button.data('code').toString();
var description = button.data('description').toString();
modal.find('form').attr('data-code', code);
modal.find('input[name=code]').val(code);
modal.find('input[name=description]').val(description);
modal.find('select[name=surcharge]').val(button.data('surcharge'));
modal.find('input[name=percentage]').val(button.data('percentage'));
if (code.length) {
modal.find('.modal-title').text('Editing Code ' + code);
modal.find('input[name=code]').prop("readonly", true);
modal.find('input[name=description]').focus();
} else {
modal.find('.modal-title').text('Adding a new Code');
modal.find('input[name=code]').prop("readonly", false);
modal.find('input[name=code]').focus();
}
}
Edit the $('#edit-code-modal').on('shown.bs.modal', function (event) { function to use the new populate_edit_from_button(button, modal) function
Add function
$("body").on("click", ".swal-edit-code", function(e) {
var button = $(this);
var code = button.data('code');
var edit_button = $('button[data-code='+code+']');
var modal = $('#edit-code-modal');
populate_edit_from_button(edit_button, modal);
swal2.close();
});
Edit $("body").on("change", "input[name=code]", function(e) { the then((result) => { part should now match
var modal = $('#edit-code-modal');
if (result.value) {
var button = $('button[data-code="'+codeID+'"]');
populate_edit_from_button(button, modal);
} else if (result.dismiss === Swal.DismissReason.cancel) {
modal.modal('hide');
}
The validate method should now have something that matches this (change description for code table) content += '<button type="button" class="btn btn-secondary swal-edit-code" data-code="'+codeID+'">Edit Customer Price Code '+ codeID +'</button>';
jform.data('codeid') should now be jform.attr('data-code')
The text was updated successfully, but these errors were encountered:
Edit form.twig add the
data-code
attribute like thisdata-code=""
it should look like
<form action="{{ page.url }}" method="POST" id="code-edit-form">
create
populate_edit_from_button(button, modal)
functionNOTE:: EDIT so it applies to the code table so it populates the right fields
Edit the
$('#edit-code-modal').on('shown.bs.modal', function (event) {
function to use the newpopulate_edit_from_button(button, modal)
functionAdd function
$("body").on("change", "input[name=code]", function(e) {
the then((result) => { part should now matchThe validate method should now have something that matches this (change description for code table)
content += '<button type="button" class="btn btn-secondary swal-edit-code" data-code="'+codeID+'">Edit Customer Price Code '+ codeID +'</button>';
jform.data('codeid')
should now bejform.attr('data-code')
The text was updated successfully, but these errors were encountered: