I know this question has already been posted, but this this topic
didn't help me. I tried the two first solutions and none worked.
The first : I get an error about options being undefined (no matter how I tried to handle it) The second : as I'm working on meteor, "this.val()" is not a value, as this do not refer to the good object.
EDIT : Here is my code
HTML :
<select class="selectpicker show-tick" id="update-languages-1" data-selected-text-format="values">
{{#each isoLangs 1}}
{{#if selected}}
<option disabled selected>{{name}}</option>
{{else}}
<option>{{name}}</option>
{{/if}}
{{/each}}
</select>
JS :
var learningLanguages = [],
options = select && select.options,
iLen = options.length;
for (var i = 0, ; i < iLen; i++)
if (options[i].selected)
learningLanguages.push(options[i].text);
As I said, I also tried with JQuery :
Template.profile.events({
'submit form': function(event, tmpl){
[...]
var learningLanguages = [];
$('#update-languages-1 :selected').each(function(){
learningLanguages.push($(this).val());
});
return false;
}
});
Could you suggest me another way to proceed ?
Thanks you