I've been having a lot of difficulty learning ember.js and ember-cli concurrently, primarily in trying to translate what's on the ember.js help docs to the ember-cli environment. I've been going in circles trying to figure out how to use dynamic segments with a field besides 'id'.
At Emberjs.com it gives an example using jQuery.getJSON and the serialize function, but I don't know
1) how to reference jquery from ember-cli (if I even need to do it the way the link above says to), and
2) It seems like no matter what I try, I get the error "cannot call method get of 'undefined'" in my serialize function
I'm currently using transitionToRoute
since I'm trying to transition from a button instead of a link-to
helper (better recommendations very welcome).
Here's the action my button uses (it's in a controller):
actions: {
viewDetails: function() {
this.transitionToRoute('project-details', this.get('projectName'));
}
}
If my route is:
this.resource('project-details', {path: '/project/:project_projectName'});
Then the Ember docs would suggest that this is what I need in my project details route, but I haven't gotten any permutation of the serializer to work, so I'm sure I'm doing something wrong, but I don't know what.
model: function(params) {
//I've tried all kinds of things in here, not sure if I need getJSON
// since right now I'm just using fixture data
//If I do need jQuery, not sure how to use it in ember-cli (i.e. the import statement to use)
return jQuery.getJSON('/project/' + params.project_projectName);
},
serialize: function(model) {
return { project_projectName: model.get('projectName') };
}
EDIT: Adding the model
var Project = DS.Model.extend({
creationDate: attr('date'),
lastModifiedDate: attr('date'),
lastModifiedResourceId: attr('string'),
ppmcNumber: attr('number'),
ppmcUrl: attr('string'),
phase: attr('string'),
staffingProfile: attr('string'),
projectType: attr('string'),
projectDesc: attr('string'),
product: attr('string'),
clientId: attr('string'),
clientName: attr('string'),
overallStatus: attr('string'),
liveDate: attr('date'),
rygStatus: function(){
return 'status-' + this.get('overallStatus').toLowerCase();
}.property('overallStatus')
});
projectName
defined? I assume the error is because "get" is not finding a value for it. – Grapho