Skip to content

Commit c082f0e

Browse files
committed
[fix] Fixed unsaved changes alert on device page
1 parent 4e16424 commit c082f0e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

openwisp_controller/config/static/config/js/relevant_templates.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,14 @@ django.jQuery(function ($) {
7373
var value = templates.join(","),
7474
templateField = templatesFieldName();
7575
$(`input[name="${templateField}"]`).attr("value", value);
76-
if (pageLoading) {
76+
if (
77+
pageLoading ||
78+
// Handle cases where the AJAX request finishes after initial page load.
79+
// If we're editing an existing object and the initial value hasn't been set,
80+
// assign it now to avoid false positives in the unsaved changes warning.
81+
(!isAddingNewObject() &&
82+
django._owcInitialValues[templateField] === undefined)
83+
) {
7784
django._owcInitialValues[templateField] = value;
7885
}
7986
$("input.sortedm2m:first").trigger("change");

0 commit comments

Comments
 (0)