Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions static/profile/js/profileeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

client.init(function loaded () {

if (c_profile !== null) {
return; // already loaded so don't load again
}

var translate = client.translate;

var defaultprofile = {
Expand Down Expand Up @@ -678,20 +682,28 @@
delete adjustedRecord.convertedOnTheFly;

console.info('saving profile');
peStatus.hide().text('saving profile').fadeIn('slow');

// Hide the form until the ajax PUT is done.
// This is a crude way of preventing the user from changing the inputs whilst waiting.
// If the user was able to make changes, they'd be lost when the done callback redraws anyway.
$('#pe_form').hide();

$.ajax({
method: 'PUT'
, url: '/api/v1/profile/'
, data: adjustedRecord
, headers: client.headers()
}).done(function postSuccess (data, status) {
console.info('profile saved', data);
$('#pe_form').show(); // allow edits again
peStatus.hide().text(status).fadeIn('slow');
record._id = data._id;
initRecord();
dirty = false;
}).fail(function(xhr, status, errorThrown) {
console.error('Profile not saved', status, errorThrown);
$('#pe_form').show(); // allow edits again
peStatus.hide().text(status).fadeIn('slow');
});
return false;
Expand Down