fix: prevent duplicate Rx-Group edit requests from repeated event binding
- use namespaced delegated handlers in opd_rx_group_workspace - call off(...namespace...) before on(...) for all click actions - resolves multiple rx_group_get calls on single Edit click after panel reopen
This commit is contained in:
parent
ab65ba0514
commit
71f24660b0
|
|
@ -60,6 +60,8 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
|
var evtNs = '.rxGroupWorkspace';
|
||||||
|
|
||||||
function getCsrfPair() {
|
function getCsrfPair() {
|
||||||
var input = document.querySelector('input[name="<?= csrf_token() ?>"]');
|
var input = document.querySelector('input[name="<?= csrf_token() ?>"]');
|
||||||
if (!input) {
|
if (!input) {
|
||||||
|
|
@ -198,24 +200,25 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('click', '.btn-rx-edit', function() {
|
// This view is loaded multiple times via AJAX; ensure only one set of handlers is active.
|
||||||
|
$(document).off('click' + evtNs, '.btn-rx-edit').on('click' + evtNs, '.btn-rx-edit', function() {
|
||||||
loadOne($(this).data('id') || 0);
|
loadOne($(this).data('id') || 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#btn_new_rx_group').on('click', function() {
|
$(document).off('click' + evtNs, '#btn_new_rx_group').on('click' + evtNs, '#btn_new_rx_group', function() {
|
||||||
clearForm();
|
clearForm();
|
||||||
setMsg('normal', 'New Rx-Group mode');
|
setMsg('normal', 'New Rx-Group mode');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#btn_save_rx_group').on('click', function() {
|
$(document).off('click' + evtNs, '#btn_save_rx_group').on('click' + evtNs, '#btn_save_rx_group', function() {
|
||||||
saveRxGroup(false);
|
saveRxGroup(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#btn_save_new_rx_group').on('click', function() {
|
$(document).off('click' + evtNs, '#btn_save_new_rx_group').on('click' + evtNs, '#btn_save_new_rx_group', function() {
|
||||||
saveRxGroup(true);
|
saveRxGroup(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#btn_open_opd_medicine').on('click', function() {
|
$(document).off('click' + evtNs, '#btn_open_opd_medicine').on('click' + evtNs, '#btn_open_opd_medicine', function() {
|
||||||
var rxId = parseInt($('#rx_id').val() || '0', 10);
|
var rxId = parseInt($('#rx_id').val() || '0', 10);
|
||||||
if (rxId <= 0) {
|
if (rxId <= 0) {
|
||||||
setMsg('err', 'Save or select Rx-Group first, then add medicines.');
|
setMsg('err', 'Save or select Rx-Group first, then add medicines.');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user