Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBS-9219: Fix editing known languages field in user profile form #472

Merged
merged 3 commits into from
Feb 20, 2017
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
9 changes: 6 additions & 3 deletions root/account/edit.tt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</span>
[% extra_field = form.field('languages').field(form.field('languages').add_extra(1) - 1) %]
<span id="add-language-template" style="display: none">
[% r.select(extra_field.field('language_id'), id => 'fluency-template', class => 'language_id',) %]
[% r.select(extra_field.field('language_id'), class => 'language_id') %]
[% r.select(extra_field.field('fluency'), class => 'fluency') %]
<span class="buttons inline">
<button type="button" class="remove negative">[% l('Remove') %]</button>
Expand All @@ -77,6 +77,9 @@

<script>//<![CDATA[
$(function () {
$(document.body).append( $('#add-language-template') );
$('#add-language-template').children().removeAttr('id').removeAttr('name');

var languageCount = $('li.language').size();

$('#edit-profile-form').on('click', 'button.remove', function (event) {
Expand All @@ -87,15 +90,15 @@
$('button.another').click(function (event) {
event.preventDefault();

languageCount++;

var newLanguage = $('<li>').append($('#add-language-template').clone().contents());
newLanguage.find('select.language_id').attr('name',
'profile.languages.' + languageCount + '.language_id');
newLanguage.find('select.fluency').attr('name',
'profile.languages.' + languageCount + '.fluency');

$(this).parents('li').before(newLanguage);

languageCount++;
});
});
//]]></script>
Expand Down