/2012/06/29/How-to-send-URL-parameters-in-Backbone-js/

{"item":{"status":"visible","url":"\/2012\/06\/29\/How-to-send-URL-parameters-in-Backbone-js\/","trash":"","name":"How-to-send-URL-parameters-in-Backbone-js","parent":"","title":"How to send URL parameters in Backbone.js","date":"2012-06-29 00:00:37","filepath":"posts\/20120629_How-to-send-URL-parameters-in-Backbone-js.xml.json","type":"post","content":"<p><a href=\"http:\/\/backbonejs.org\/\"><img style=\"margin-left: 10px; margin-right: 10px; float: left;\" src=\"http:\/\/www.8bitrobot.com\/media\/uploads\/backbone-300x300.png\" alt=\"\" width=\"72\" \/><\/a>Say you want to request a collection from the server in <a href=\"http:\/\/backbonejs.org\/\">backbone.js<\/a>, but don't want to receive every single item available. &nbsp;Instead, you want to receive only the first 100 items. &nbsp;Well, <a href=\"http:\/\/api.jquery.com\/jQuery.ajax\/\">jQuery.ajax<\/a> options can be passed directly as fetch options.&nbsp;<sup><a href=\"http:\/\/backbonejs.org\/#Collection-fetch\">docs<\/a><\/sup><\/p>\n<p>So, when you want to fetch the collection call the following:<\/p>\n<pre style=\"padding-left: 30px;\">instance_of_your_collection.fetch({data: {count: 100}});<\/pre>\n<p>If there are problems with the above, try parameterizing the data:<\/p>\n<pre style=\"padding-left: 30px;\">instance_of_your_collection.fetch({data: $.param({count: 100})});<\/pre>\n<p>On the server side, if you are using the <a href=\"http:\/\/www.slimframework.com\">Slim Framework<\/a>&nbsp;with PHP, you can check the parameters like so:<\/p>\n<pre style=\"padding-left: 30px;\">$app-&gt;request()-&gt;params('count');<\/pre>\n<p>&nbsp;<\/p>"}}
comments powered by Disqus
 

Lorem Ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

 
This page is best viewed with Firefox 3.5+, Chrome 5+, Safari 5+, Opera 10.6+, IE 9+
Copyright © 2014 8bitrobot.com