I'm new to Ember, so another Ember question - I have a template which contains a form. The form contains two select objects and a submit button. The select objects are components. What I'm having trouble with is getting the selected value of the select objects when the submit button is clicked. Here is the template code for one of the select objects:
{{
view
content=relationshipTypes
value=selectedRelationshipType
selection=selectedRelationshipType
prompt="Select Relationship Type..."
}}
Here is the component.js code for the select object:
export default Ember.Component.extend({
classNames: 'btn-group relationship-type-select'.w(),
change: function(event) {
var typeSelected = this.get('selectedRelationshipType');
this.set('selectedRelationshipType', typeSelected);
}
});
And in the route.js for the template that contains the submit button (with an action for createRelationship):
export default Ember.Route.extend({
model: function() {
return this.modelFor('people.show').get('entityRelationships');
},
setupController(controller) {
this._super.apply(this, arguments);
controller.set('person', this.modelFor('people.show'));
},
actions: {
relationshipEntityTypeSelected: function(type) {
console.log("IN RELATIONSHIPENTITYTYPESELECTED.TYPE");
this.set('selectedRelationshipType');
},
createRelationship: function() {
var fromEmfId = this.modelFor('people.show').id
console.log("FROM EMF ID==>" + fromEmfId);
var toEmfId = "";
var relationshipType = this.get('selectedRelationshipType');
console.log("RELATIONSHIP-TYPE==>" + relationshipType);
}
}
});
So all I want is to be able to get the selected relationship type in the createRelationship function, but I have been unable to do it so far. If anyone can tell me what I'm doing wrong, I would appreciate it. Thanks.
Aucun commentaire:
Enregistrer un commentaire