Selecting a collection with a search term in Backbone.js

I am trying to create a collection in the trunk that calls /search/:searchTerm on the server when fetching. I have the following line:

 this.collection.fetch({ data: {searchTerm: "user input"} }); 

Firebug tells me that this leads to GET http: // localhost: 4242 / search? [object% 20Object] Can this be done by writing the ajax call itself on the trunk router, or is there a smoother, faster way?

+8
source share
1 answer

I had the same problem, but using jQuery.param seems to fix it, i.e.

 this.collection.fetch({ data: jQuery.param({searchTerm: "user input"}) }); 
+6
source share

All Articles