1

Enter key adds new categories, fix profile view.

This commit is contained in:
Alex Yatskov 2015-03-11 19:07:43 +09:00
parent e680b10362
commit 3dd296def2

View File

@ -40,12 +40,11 @@
return; return;
} }
var categories = {}; var categories = [{
id: results.id,
categories[results.id] = { value: getProfileValue(results.id),
description: results.description, description: results.description
value: getProfileValue(results.id) }];
};
displayCategories(categories); displayCategories(categories);
}); });
@ -81,6 +80,11 @@
}); });
} }
function submitCategory() {
addCategory($('#newCategory').val());
$('#newCategory').val('');
}
$(document).ready(function() { $(document).ready(function() {
Handlebars.registerHelper('checkMatch', function(value, options) { Handlebars.registerHelper('checkMatch', function(value, options) {
return new Handlebars.SafeString(value == this.value ? 'checked' : ''); return new Handlebars.SafeString(value == this.value ? 'checked' : '');
@ -88,8 +92,11 @@
refreshCategories(); refreshCategories();
$('#addCategory').click(function() { $('#addCategory').click(submitCategory);
addCategory($('#newCategory').val()); $('#newCategory').keyup(function(e) {
if (e.keyCode == 13) {
submitCategory();
}
}); });
}); });
})(); })();