I have a schedule/calendar app that I wrote in Rails that I’m rewriting using Backbone (and Rails, still).
In the old app, when you would click a time slot to make a new appointment, it would pass the date and time in the query string.
For Backbone, maybe I want to do the same thing. I’m apprehensive, though, because 1) I don’t know how to read the query string with Backbone (which isn’t a big deal – I can figure that out) and, more importantly, 2) maybe Backbone offers a way to pass this data that’s better than what I was doing before.
So my question is: should I pass the date/time data in the query string or does Backbone have a better way that I haven’t thought of? The query string solution has always felt a little clunky, so I thought I’d check.
Backbone implements a REST API out of the box, which you should try to follow as much as possible.
For the purpose of creating a new Appointment. You’d basically make a new instance of AppointmentModel, which extends Backbone.Model. Define the URL as “/api/appointments” or something similar.
Calling appointmentModel1.save() will issue a POST to /api/appointments containing all the data in the model.
Don’t use QueryStrings – or you’ll end up overriding the backbone URLs EVERYWHERE and will loose a lot of functionality that backbone can take care of for you.