Skip to content

Commit

Permalink
Merge pull request #101 from JadynWong/jadyn/fix-100
Browse files Browse the repository at this point in the history
Fix save event for custom groups on first navigation
  • Loading branch information
blackWins committed Dec 25, 2023
2 parents e9f5921 + 7a04f75 commit 8bb3815
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
Expand Up @@ -5,7 +5,7 @@

@foreach (var group in Model.GroupBy(sd => sd.Group2))
{
<form method="post" id="@(group.Key)SettingGroup">
<form method="post" id="@(group.Key)SettingGroup" class="setting-ui">
<abp-card class="mb-3">
<abp-card-header>
<h4>@L[group.Key]</h4>
Expand Down
Expand Up @@ -4,12 +4,8 @@
var l = abp.localization.getResource("EasyAbpAbpSettingUi");

var event_fn = function (id = '') {
$(id + "form").submit(function (e) {
$(id + " form.setting-ui").submit(function (e) {
e.preventDefault();
// Skip abp `EmailSettingsForm`
if (e.currentTarget.id == 'EmailSettingsForm') {
return;
}

if (!$(e.currentTarget).valid()) {
return;
Expand All @@ -23,7 +19,7 @@
});
});

$(id + ".reset").click(function (e) {
$(id + " form.setting-ui .reset").click(function (e) {
var form = e.currentTarget.closest("form");
abp.message.confirm(
l("ResetConfirm", $(form).find("h4").text()),
Expand All @@ -46,23 +42,37 @@
})
}

var bind_nav_event_fn = function (element) {
var btn_set = setInterval(function () {
var _id = '#' + element.data('id').replace(/\./g, '-');
if ($(_id + " form.setting-ui").length > 0) {
event_fn(_id);
clearInterval(btn_set);
return;
}

// Rendering is done but not SettingUi.
var target = element.attr('data-bs-target');
if (target !== undefined && $(target).length > 0) {
clearInterval(btn_set);
}
}, 200);
}

$('#tabs-nav .nav-item .nav-link').click(function () {
var _this = $(this);
if (_this.attr('data-bs-target') !== undefined) {
return;
}
var btn_set = setInterval(function () {
var _id = '#' + _this.data('id') + " ";
event_fn(_id);
if ($(_id + " form").length > 0) {
clearInterval(btn_set);
}
}, 200);
bind_nav_event_fn(_this)
});

if (location.hash) {
var index = location.hash.substring(1);
$("#SettingManagementWrapper li.nav-item > a.nav-link")[index].click();
$("#tabs-nav .nav-item .nav-link")[index].click();
history.replaceState(null, null, ' '); // remove hash from the location url
}

// The first nav will automatically click and loading before on this script.
bind_nav_event_fn($("#tabs-nav .nav-item .nav-link").first());
})(jQuery);

0 comments on commit 8bb3815

Please sign in to comment.