Trying to retrieve a specific item from a collection using Backbone has been quite challenging for me. Despite referencing the documentation and looking at examples like Backbone.js fetch with parameters, I still find myself unsure of the correct syntax.
This is my attempt so far:
var accounts, myJob;
accounts = new JobCollection();
myJob = accounts.fetch({
data: $.param({
id: '7a107f87-be69-5efa-107c-c045e75940cf'
})
});
return console.log(myJob);
How can I successfully fetch the job with an ID of 7a107f87-be69-5efa-107c-c045e75940cf?
Below is the CoffeeScript used to define the collection:
class JobCollection extends Backbone.Collection
localStorage: new Backbone.LocalStorage("cl-job")
url:'/jobs'