Hi all, im having an issue using my models findOne method to get updated
data from my server.
I have a model representing meetups, or events, on the UI side it has an attribute 'attendees' which is a list of users. Users can RSVP or un-RSVP to events by clicking on a button in the ui which hits an endpoint that deletes or creates an entry in a pivot table that my backend model uses to create the meetup datashape.
After performing such an action I want to pull in the latest meetup information again, so I call the findone method. After an RSVP, there no problem, but after an UN-RSVP the model is not being updated with the data that gets returned from the server, in fact the data passed to the done function does not match the data returned from the server.For example if i have the following code:
I have a model representing meetups, or events, on the UI side it has an attribute 'attendees' which is a list of users. Users can RSVP or un-RSVP to events by clicking on a button in the ui which hits an endpoint that deletes or creates an entry in a pivot table that my backend model uses to create the meetup datashape.
After performing such an action I want to pull in the latest meetup information again, so I call the findone method. After an RSVP, there no problem, but after an UN-RSVP the model is not being updated with the data that gets returned from the server, in fact the data passed to the done function does not match the data returned from the server.For example if i have the following code:
App.Models.Meetup.findOne(meetupId)
.done(function(resp) {
console.log(resp.attr())
})
If i look in the network inspector I see:
{"created_at":"2014-10-23 01:53:37","updated_at":"2014-10-29 23:11:57","id":"1","attendees":[],"comments":[]}
but the following is logged to the console:
Ive omitted the other data that isn't relevant
{"created_at":"2014-10-23 01:53:37","updated_at":"2014-10-29 23:11:57","id":"1","attendees":[],"comments":[]}
but the following is logged to the console:
- "id":"1",
- "created_at":"2014-10-23 01:53:37",
- "updated_at":"2014-10-29 23:11:57",
-
"attendees":
[
-
{
- "created_at":"2014-10-22 23:25:01",
- "updated_at":"2014-10-28 01:38:45",
- "id":"331",
- "city_id":"7",
- "team_id":"3",
- "email":"al.quirk@gmail.com",
- "aboutme":"",
- "avatarUrl":"/content/images/avatars/default_avatar02.png",
- "firstname":"Alex",
- "lastname":"Quirk",
-
"pivot":
{
- "meetup_id":"1",
- "user_id":"331"
-
{
-
"comments":
[
Ive omitted the other data that isn't relevant