summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Davis <thomasalwyndavis@gmail.com>2011-10-20 22:30:10 -0700
committerThomas Davis <thomasalwyndavis@gmail.com>2011-10-20 22:30:10 -0700
commit0d16b4481d7b09d6a4d806b58dd45392c888d787 (patch)
treeaeebe005b22913a637811718901db0dab2d6542a
parentb9fb5fab93b1f683387f65db715ca8386d2b47b2 (diff)
parent337aadc7e68b1d2ee594535e2239e08a8343c2ef (diff)
downloadbackbonetutorials-0d16b4481d7b09d6a4d806b58dd45392c888d787.zip
backbonetutorials-0d16b4481d7b09d6a4d806b58dd45392c888d787.tar.gz
backbonetutorials-0d16b4481d7b09d6a4d806b58dd45392c888d787.tar.bz2
Merge pull request #19 from paulirish/patch-1
clarifying passing in arguments. slight formatting diff in code sample.
-rw-r--r--_posts/2011-01-27-what-is-a-router.textile14
1 files changed, 8 insertions, 6 deletions
diff --git a/_posts/2011-01-27-what-is-a-router.textile b/_posts/2011-01-27-what-is-a-router.textile
index 2b0fdc6..db2a649 100644
--- a/_posts/2011-01-27-what-is-a-router.textile
+++ b/_posts/2011-01-27-what-is-a-router.textile
@@ -77,7 +77,7 @@ h4. Dynamic Routing Cont. ":params" and "*splats"
p. Backbone uses two styles of variables when implementing routes. First there are ":params" which match any URL components between slashes. Then there are "*splats" which match any number of URL components. Note that due to the nature of a "*splat" it will always be the last variable in your URL as it will match any and all components.
-Any "*splats" or ":params" in route definitions are passed as variables respective order to the associated function. A route defined as "/:route/:action" will pass 2 variables(route, action) to the call back function. Which can be accessed with "function( route, action )". (If this is confusing please post a comment and I will try articulate it better)
+Any "*splats" or ":params" in route definitions are passed as arguments (in respective order) to the associated function. A route defined as "/:route/:action" will pass 2 variables (“route” and “action”) to the callback function. (If this is confusing please post a comment and I will try articulate it better)
Here are some examples of using ":params" and "*splats"
@@ -96,14 +96,16 @@ Here are some examples of using ":params" and "*splats"
},
- getPost: function( id ){ alert(id); /* 121 */ },
- downloadFile: function( path ){ alert(path); /* user/images/hey.gif */ },
+ getPost: function( id ){
+ alert(id); // 121
+ },
+ downloadFile: function( path ){
+ alert(path); // user/images/hey.gif
+ },
loadView: function( route, action ){
- alert(route + "_" + action);
- /* dashboard_graph */
+ alert(route + "_" + action); // dashboard_graph
}
-
{% endhighlight %}
p. Routes are quite powerful and in an ideal world your application should never contain too many. If you need to implement hash tags with SEO in mind, do a google search for "google seo hashbangs".