VRFS-867 preselect assigned genres when editing band details

This commit is contained in:
Brian Smith 2013-12-01 17:53:24 -05:00
parent 6e180b86d1
commit 3e1e05e378
3 changed files with 22 additions and 8 deletions

View File

@ -252,7 +252,7 @@
$("#band-website").val(band.website);
$("#band-biography").val(band.biography);
loadGenres();
loadGenres(band.genres);
loadCountries(band.country, function() {
loadRegions(band.state, function () {
@ -287,13 +287,27 @@
$(".autocomplete").width("150px");
}
function loadGenres() {
rest.getGenres().done(function(response) {
$.each(response, function(index, val) {
function loadGenres(selectedGenres) {
$("band-genres").empty();
rest.getGenres().done(function(genres) {
$.each(genres, function(index, genre) {
var genreTemplate = $('#template-band-setup-genres').html();
var selected = '';
if (selectedGenres) {
var genreMatch = $.grep(selectedGenres, function(n,i) {
return n.id === genre.id;
});
if (genreMatch.length > 0) {
selected = "checked";
}
}
var genreHtml = context.JK.fillTemplate(genreTemplate, {
id: val.id,
description: val.description
id: genre.id,
description: genre.description,
checked: selected
});
$('#band-genres').append(genreHtml);

View File

@ -138,7 +138,7 @@
});
}
function getCities (options) {
function getCities(options) {
var country = options['country']
var region = options['region']

View File

@ -132,7 +132,7 @@
</div>
<script type="text/template" id="template-band-setup-genres">
<tr><td><input value="{id}" type="checkbox" />{description}</td></tr>
<tr><td><input value="{id}" {checked} type="checkbox" />{description}</td></tr>
</script>
<script type="text/template" id="template-band-invitation">