diff --git a/web/app/assets/javascripts/accounts_profile_experience.js b/web/app/assets/javascripts/accounts_profile_experience.js index 3e0b1efb6..53a9a2c78 100644 --- a/web/app/assets/javascripts/accounts_profile_experience.js +++ b/web/app/assets/javascripts/accounts_profile_experience.js @@ -9,14 +9,14 @@ var EVENTS = context.JK.EVENTS; var api = context.JK.Rest(); var $screen = $('#account-profile-experience'); - var $scroller = $screen.find('#account-profile-content-scroller'); - var $instrumentSelector = null; - var $userGenres = null; var profileUtils = context.JK.ProfileUtils; var $btnCancel = $screen.find('#account-edit-profile-cancel'); var $btnBack = $screen.find('#account-edit-profile-back'); var $btnSubmit = $screen.find('#account-edit-profile-submit'); + var $instrumentSelector = $screen.find('.instrument_selector'); + var $userGenres = $screen.find('#user-genres'); + function beforeShow(data) { } @@ -26,23 +26,15 @@ } function resetForm() { - $scroller.find('form .error-text').remove(); - $scroller.find('form .error').removeClass("error"); + $screen.find('form .error-text').remove(); + $screen.find('form .error').removeClass("error"); } function populateAccountProfile(userDetail, instruments) { - var template = context.JK.fillTemplate($('#template-account-profile-experience').html(), { - user_instruments: userDetail.instruments - }); - - $scroller.html(template); - - $instrumentSelector = $screen.find('.instrument_selector'); - $userGenres = $screen.find('#user-genres'); - events(); loadGenres(profileUtils.profileGenres(userDetail.genres)); + $instrumentSelector.empty(); $.each(instruments, function(index, instrument) { var template = context.JK.fillTemplate($('#account-profile-instrument').html(), { checked : isUserInstrument(instrument, userDetail.instruments) ? "checked=\"checked\"" :"", @@ -55,15 +47,15 @@ // and fill in the proficiency for the instruments that the user can play if(userDetail.instruments) { $.each(userDetail.instruments, function(index, userInstrument) { - $('tr[data-instrument-id="' + userInstrument.instrument_id + '"] select.proficiency_selector', $scroller).val(userInstrument.proficiency_level); + $('tr[data-instrument-id="' + userInstrument.instrument_id + '"] select.proficiency_selector', $screen).val(userInstrument.proficiency_level); }); } - $scroller.find('select[name=skill_level]').val(userDetail.skill_level); - $scroller.find('select[name=concert_count]').val(userDetail.concert_count); - $scroller.find('select[name=studio_session_count]').val(userDetail.studio_session_count); + $screen.find('select[name=skill_level]').val(userDetail.skill_level); + $screen.find('select[name=concert_count]').val(userDetail.concert_count); + $screen.find('select[name=studio_session_count]').val(userDetail.studio_session_count); - context.JK.dropdown($('select', $scroller)); + context.JK.dropdown($('select', $screen)); } function isUserInstrument(instrument, userInstruments) { @@ -122,6 +114,7 @@ function events() { $btnCancel.click(function(evt) { + console.log("HERE"); evt.stopPropagation(); navigateTo('/client#/profile/' + context.JK.currentUserId); return false; @@ -158,16 +151,15 @@ function handleUpdateProfile() { resetForm(); - var instruments = getInstrumentsValue(); + var instruments = getSelectedInstruments(); var genres = getSelectedGenres(); - var status = api.updateUser({ instruments: instruments, genres: genres, - skill_level: $scroller.find('select[name=skill_level]').val(), - concert_count: $scroller.find('select[name=concert_count]').val(), - studio_session_count: $scroller.find('select[name=studio_session_count]').val() + skill_level: $screen.find('select[name=skill_level]').val(), + concert_count: $screen.find('select[name=concert_count]').val(), + studio_session_count: $screen.find('select[name=studio_session_count]').val() }) .done(postUpdateProfileSuccess) .fail(postUpdateProfileFailure); @@ -186,7 +178,7 @@ var instruments = context.JK.format_errors("musician_instruments", errors); if(instruments != null) { - instrumentSelector.closest('div.field').addClass('error').append(instruments); + $instrumentSelector.closest('div.field').addClass('error').append(instruments); } } else { @@ -194,7 +186,7 @@ } } - function getInstrumentsValue() { + function getSelectedInstruments() { var instruments = []; $('input[type=checkbox]:checked', $instrumentSelector).each(function(i) { @@ -217,7 +209,10 @@ 'beforeShow': beforeShow, 'afterShow': afterShow }; + app.bindScreen('account/profile/experience', screenBindings); + + events(); } this.initialize = initialize; diff --git a/web/app/views/clients/_account_profile_experience.html.erb b/web/app/views/clients/_account_profile_experience.html.erb index 55a731ba7..5360c22b9 100644 --- a/web/app/views/clients/_account_profile_experience.html.erb +++ b/web/app/views/clients/_account_profile_experience.html.erb @@ -9,81 +9,75 @@
+
-