I’m trying to connect with my server to pass a POST request in JSON.
The URL I send it to, however, depends on the id
being viewed on the template. So if I’m looking at a “group” with the ID 1100, the URL should be http://localhost:3100/api/groups/1100/something/start
.
I just can’t figure out how to get the group id
in there. Trying, but no dice:
jQuery.ajax({
url: "/api/groups/"+ params.group_id +"/something/start",
type: 'post',
contentType: 'application/json',
dataType: 'json'
});
},
Some more useful info:
My route:
App.IndexRoute = Ember.Route.extend({
sortProperties: ['id'],
sortAscending: true,
actions: {
toggleMenu: function() {
this.controller.toggleProperty('menuVisible');
this.controller.pushBody();
}
},
model: function() {
var store = this.store;
var url = '/api/groups/top?subscribe=true';
$.getJSON(url).then(function(data) {
store.pushMany('group', data.data.groups);
});
return this.store.all('group');
}
});
Controller:
App.IndexController = Em.ArrayController.extend({
sortProperties: ['name'],
sortAscending: true,
menuVisible: false,
actions: {
poweron: function(){
jQuery.ajax({
url: "/api/groups/"+ params.group_id +"/something/start",
type: 'post',
contentType: 'application/json',
dataType: 'json'
});
}
});
Thoughts? Thanks!
Any thoughts?
Thanks!