moved guild change bind to after guilds loaded

This commit is contained in:
Corban-Lee Jones 2024-03-26 16:47:03 +00:00
parent 2978f99eeb
commit 4e92809b87

View File

@ -320,10 +320,6 @@
$(document).ready(function() {
loadGuilds();
loadSubscriptions();
$("#editSubServer").change(function() {
loadChannels($(this).find("option:selected").attr("value"));
});
});
function loadGuilds() {
@ -331,13 +327,19 @@
url: "/guilds",
type: "GET",
success: function(response) {
// Add each guild as a selectable option
for (i = 1; i < response.length; i++) {
var guild = response[i];
$("#editSubServer").append($("<option>", {
value: guild.id,
text: guild.name
}));
var option = $("<option>", {text: guild.name, value: guild.id})
$("#editSubServer").append(option);
}
// Bind the select to update channels on change
$("#editSubServer").change(function() {
var selectedGuildId = $(this).find("option:selected").attr("value");
loadChannels(selectedGuildId);
});
},
error: function(response) {
console.error(JSON.stringify(response, null, 4));