diff --git a/web/app/assets/javascripts/accounts_profile.js b/web/app/assets/javascripts/accounts_profile.js index 5c7cb6123..d904f5f0e 100644 --- a/web/app/assets/javascripts/accounts_profile.js +++ b/web/app/assets/javascripts/accounts_profile.js @@ -4,7 +4,9 @@ context.JK = context.JK || {}; context.JK.AccountProfileScreen = function(app) { + var $document = $(document); var logger = context.JK.logger; + var EVENTS = context.JK.EVENTS; var api = context.JK.Rest(); var userId; var user = {}; @@ -63,6 +65,7 @@ $('select#user_birth_date_1i', content_root).val(parseInt(birthDateYear)); $('select#user_birth_date_2i', content_root).val(parseInt(birthDateMonth)); $('select#user_birth_date_3i', content_root).val(parseInt(birthDateDay)); + } // update instruments @@ -87,6 +90,7 @@ } context.JK.dropdown($('select', content_root)); + } function isUserInstrument(instrument, userInstruments) { @@ -317,7 +321,9 @@ .always(function() { loadingCitiesData = false;}) } } + }) + context.JK.dropdown($('select')); } function navToAccount() { @@ -366,6 +372,9 @@ }, null, true); + + $document.triggerHandler(EVENTS.USER_UPDATED, response); + } function postUpdateProfileFailure(xhr, textStatus, errorMessage) { diff --git a/web/app/assets/javascripts/accounts_profile_avatar.js b/web/app/assets/javascripts/accounts_profile_avatar.js index 388bed37c..c89039d97 100644 --- a/web/app/assets/javascripts/accounts_profile_avatar.js +++ b/web/app/assets/javascripts/accounts_profile_avatar.js @@ -6,6 +6,7 @@ context.JK.AccountProfileAvatarScreen = function(app) { var self = this; var logger = context.JK.logger; + var EVENTS = context.JK.EVENTS; var rest = context.JK.Rest(); var user = {}; var tmpUploadPath = null; @@ -381,9 +382,9 @@ self.userDetail = response; // notify any listeners that the avatar changed - userDropdown.loadMe(); + // userDropdown.loadMe(); // $('.avatar_large img').trigger('avatar_changed', [self.userDetail.photo_url]); - + $(document).triggerHandler(EVENTS.USER_UPDATED, response); app.notify( { title: "Avatar Changed", text: "You have updated your avatar successfully." diff --git a/web/app/assets/javascripts/globals.js b/web/app/assets/javascripts/globals.js index 087e0213d..309c40509 100644 --- a/web/app/assets/javascripts/globals.js +++ b/web/app/assets/javascripts/globals.js @@ -32,8 +32,9 @@ SHOW_SIGNUP : 'show_signup', SHOW_SIGNIN : 'show_signin', RSVP_SUBMITTED: 'rsvp_submitted', - RSVP_CANCELED : 'rsvp_canceled' - } + RSVP_CANCELED : 'rsvp_canceled', + USER_UPDATED : 'user_updated' + }; context.JK.ALERT_NAMES = { NO_EVENT : 0, diff --git a/web/app/assets/javascripts/user_dropdown.js b/web/app/assets/javascripts/user_dropdown.js index 656ce71ab..3242ec824 100644 --- a/web/app/assets/javascripts/user_dropdown.js +++ b/web/app/assets/javascripts/user_dropdown.js @@ -6,7 +6,7 @@ context.JK = context.JK || {}; context.JK.UserDropdown = function (app) { - + var EVENTS = context.JK.EVENTS; var logger = context.JK.logger; var rest = new JK.Rest(); var userMe = null; @@ -53,12 +53,16 @@ $('.shortcuts .test-network').on('click', function(e) { app.layout.showDialog('network-test'); return false; - }) + }); $('#header-avatar').on('avatar_changed', function (event, newAvatarUrl) { updateAvatar(newAvatarUrl); event.preventDefault(); return false; + }); + $(document).on(EVENTS.USER_UPDATED, function(e, data) { + userMe = data; + updateHeader(); }) } @@ -115,5 +119,8 @@ loadMe(); } this.loadMe = loadMe; + } -})(window, jQuery); \ No newline at end of file +})(window, jQuery); + + diff --git a/web/app/views/clients/_account_profile.html.erb b/web/app/views/clients/_account_profile.html.erb index bf1ec484f..c297b0f7b 100644 --- a/web/app/views/clients/_account_profile.html.erb +++ b/web/app/views/clients/_account_profile.html.erb @@ -79,7 +79,7 @@