Created
May 15, 2014 23:43
-
-
Save joshbedo/11b1c5097590c1a0ed3b to your computer and use it in GitHub Desktop.
Backbone collection url() snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test = { | |
urlRoot: "http://google.com", | |
url: function(options) { | |
var path; | |
if(options && options.param && options.query) { | |
path = "?" + options.param + "=" + options.query; | |
} | |
return (path) ? this.urlRoot + path : this.urlRoot; | |
} | |
} | |
console.log(test.url()); | |
console.log(test.url({ param: "keyword", query: "test"})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment