diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js
index 435f59f107..a0573057e0 100644
--- a/public/src/admin/admin.js
+++ b/public/src/admin/admin.js
@@ -14,7 +14,7 @@
activateMobile();
}
- $(window).on('action:ajaxify.end', function(ev, data) {
+ $(window).on('action:ajaxify.contentLoaded', function(ev, data) {
var url = data.url;
selectMenuItem(data.url);
@@ -23,6 +23,8 @@
setupCheckboxes();
});
+ $(window).on('action:admin.settingsLoaded', setupCheckboxes);
+
$('[component="logout"]').on('click', app.logout);
$(window).resize(setupHeaderMenu);
@@ -175,31 +177,32 @@
return $('[type=checkbox]').show();
}
+ $('[type=checkbox]').change(function() {
+ var checked = $(this).is(':checked');
+
+ $(this).siblings('[class*=fa-]').toggleClass('fa-toggle-off', !checked)
+ .toggleClass('fa-toggle-on', checked);
+ });
+
$('[type=checkbox]').each(function() {
var checkbox = $(this),
checked = checkbox.is(':checked');
+ if (checkbox.attr('data-toggle-added')) {
+ return;
+ }
+
checkbox.hide();
+
if (checked) {
checkbox.after('');
}
else {
checkbox.after('');
}
- });
-
- $('[type=checkbox]').change(function() {
- var checked = $(this).is(':checked');
- $(this).siblings('[class*=fa-]').toggleClass('fa-toggle-off', !checked)
- .toggleClass('fa-toggle-on', checked);
+ checkbox.attr('data-toggle-added', true);
});
-
- $.propHooks.checked = {
- set: function(elem, value, name) {
- $(elem).trigger("change");
- }
- };
}
}());
\ No newline at end of file
diff --git a/public/src/admin/settings.js b/public/src/admin/settings.js
index 98ab422b14..9fc436a2e7 100644
--- a/public/src/admin/settings.js
+++ b/public/src/admin/settings.js
@@ -104,6 +104,8 @@ define('admin/settings', ['uploader', 'sounds'], function(uploader, sounds) {
if (typeof callback === 'function') {
callback();
}
+
+ $(window).trigger('action:admin.settingsLoaded');
};
function handleUploads() {
diff --git a/public/src/modules/settings.js b/public/src/modules/settings.js
index 17302ea1d1..d541b35e84 100644
--- a/public/src/modules/settings.js
+++ b/public/src/modules/settings.js
@@ -471,6 +471,7 @@ define('settings', function () {
}
$(formEl).deserialize(values);
+ $(window).trigger('action:admin.settingsLoaded');
callback(null, values);
});