vendredi 23 septembre 2016

Can't get current value from select in Ember 2

I'm trying to get the value every time the user changes the select component. But the value always returns 'undefined'.

I've been through all Stackoverflow questions and other sites, but without success. I feel like I'm missing something here. I'm using Ember 2.8.

My component template:

<div class="form-group">
    <label for=""></label>
    <select name="" id="" class="form-control" >
        <option value="0" selected></option>
        
            <option value=></option>
        
    </select>
</div>

My component logic:

import Ember from 'ember';

export default Ember.Component.extend({
    tagName: '',
    currentValue: null,
    actions: {
        getSelectValue(value) {
            console.log(value); //always returns undefined
        }
    }
});

I'm calling it like this:



In the template I've also used the onchange="" syntax, but then the action wasn't called.

At this point I have no logic in my route or controller handling this.

Thanks for your help!




Aucun commentaire:

Enregistrer un commentaire