VRFS-867 preload location data correctly when editing band details
This commit is contained in:
parent
95954f4789
commit
6e180b86d1
|
|
@ -230,32 +230,35 @@
|
|||
function afterShow(data) {
|
||||
friendSelectorDialog.setCallback(friendSelectorCallback);
|
||||
loadFriends();
|
||||
loadGenres();
|
||||
|
||||
if (bandId) {
|
||||
$("#band-setup-title").html("edit band");
|
||||
$("#btn-band-setup-save").html("SAVE CHANGES");
|
||||
|
||||
// retrieve and initialize band profile data points
|
||||
initializeForm();
|
||||
loadBandDetails();
|
||||
}
|
||||
else {
|
||||
loadCountries('');
|
||||
loadGenres();
|
||||
loadCountries();
|
||||
$("#band-setup-title").html("set up band");
|
||||
$("#btn-band-setup-save").html("CREATE BAND");
|
||||
}
|
||||
}
|
||||
|
||||
function initializeForm() {
|
||||
function loadBandDetails() {
|
||||
rest.getBand(bandId).done(function(band) {
|
||||
$("#band-name").val(band.name);
|
||||
$("#band-website").val(band.website);
|
||||
$("#band-biography").val(band.biography);
|
||||
$("#band-country").val(band.country);
|
||||
|
||||
loadCountries(band.country);
|
||||
loadRegions(band.state);
|
||||
loadCities(band.city);
|
||||
loadGenres();
|
||||
|
||||
loadCountries(band.country, function() {
|
||||
loadRegions(band.state, function () {
|
||||
loadCities(band.city);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: initialize avatar
|
||||
});
|
||||
|
|
@ -298,7 +301,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
function loadCountries(initialValue) {
|
||||
function loadCountries(initialCountry, onCountriesLoaded) {
|
||||
var $country = $("#band-country");
|
||||
|
||||
var nilOption = $('<option value=""></option>');
|
||||
|
|
@ -312,16 +315,20 @@
|
|||
option.text(country);
|
||||
option.attr("value", country);
|
||||
|
||||
if (initialValue === country) {
|
||||
option.attr("selected", true);
|
||||
if (initialCountry === country) {
|
||||
option.attr("selected", "selected");
|
||||
}
|
||||
|
||||
$country.append(option);
|
||||
});
|
||||
|
||||
if (onCountriesLoaded) {
|
||||
onCountriesLoaded();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadRegions(initialValue) {
|
||||
function loadRegions(initialRegion, onRegionsLoaded) {
|
||||
$("#band-region").empty();
|
||||
var selectedCountry = $("#band-country").val();
|
||||
var $region = $("#band-region");
|
||||
|
|
@ -337,16 +344,20 @@
|
|||
option.text(region);
|
||||
option.attr("value", region);
|
||||
|
||||
if (initialValue === region) {
|
||||
option.attr("selected", true);
|
||||
if (initialRegion === region) {
|
||||
option.attr("selected", "selected");
|
||||
}
|
||||
|
||||
$region.append(option);
|
||||
});
|
||||
|
||||
if (onRegionsLoaded) {
|
||||
onRegionsLoaded();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadCities(initialValue) {
|
||||
function loadCities(initialCity) {
|
||||
$("#band-city").empty();
|
||||
var selectedCountry = $("#band-country").val();
|
||||
var selectedRegion = $("#band-region").val();
|
||||
|
|
@ -363,8 +374,8 @@
|
|||
option.text(city);
|
||||
option.attr("value", city);
|
||||
|
||||
if (initialValue === city) {
|
||||
option.attr("selected", true);
|
||||
if (initialCity === city) {
|
||||
option.attr("selected", "selected");
|
||||
}
|
||||
|
||||
$city.append(option);
|
||||
|
|
|
|||
Loading…
Reference in New Issue