Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a Collection's url

Tags:

backbone.js

let's say I have :

var Book = Backbone.Model.extend();  var Collection = Backbone.Collection.extend({   model: Book,   url: '/books',   initialize: function(){     this.fetch();   }) }) 

How can I change the Collection's url when instantiating a new collection ?

var AdventureBooks = new Books({ url: '/books/adventure' }) does not work

var AdventureBooks = new Books({ category: 'adventure' }) 

and in the Collection definition:

url : '/books/' + this.category does not work either.

Thanks.

like image 876
Running Turtle Avatar asked Jun 07 '11 09:06

Running Turtle


People also ask

How do I change my Shopify collection URL?

Step 1: Go to Shopify Admin > Products > All products or Shopify Admin > Products > Collections and then select your preferred one. Step 2: Under the Search engine listing preview section, click on “Edit website SEO.” Enter your preferred URL in the URL and handle field.

How do I link an item to a collection on Shopify?

From your Shopify admin, go to Products. Click the product that you want to add to a collection. In the Collections section, select one or more existing collections. Click Save to add the product to all the selected collections.

Can you change the name collections in Shopify?

Change the name or description of a collectionFrom your Shopify admin, go to Products > Collections. Click the name of the collection that you want to update. On the collection details page, enter a new title or a new description. Click Save.


2 Answers

The following should work:

var AdventureBooks = new Books(); AdventureBooks.url = '/books/adventure'; 
like image 137
ponzao Avatar answered Sep 24 '22 17:09

ponzao


var Book = Backbone.Model.extend({   "url": function() {     return '/books/' + this.get("category");   } }); 
like image 37
Raynos Avatar answered Sep 25 '22 17:09

Raynos