backbone.js-collections

Sync collection changes with the backend

眉间皱痕 提交于 2019-12-20 07:47:42
问题 I use Backbone.js and I have a collections of models. This collection is retrieved and displayed on the front-end. On the front-end, I want the user to remove and add new models to the collection. When the user is finished and he clicked "save", I want the entire collection to be updated. Meaning that when clicking 'save', the collection is synced (somehow). Added models are saved and removed models are deleted. If I manipulate the collection by removing and adding models, and then use ex:

Backbone.js What is the purpose of specifying a model in collection

社会主义新天地 提交于 2019-12-19 11:15:31
问题 Here is what I am trying to understand. Often times I find myself writing backbone like this: var CallModel = Backbone.Model.extend({ }); var CallsCollection = Backbone.Collection.extend({ model: CallModel, url: 'url/to/external/json' }); It is a very basic example but as you can see, there is nothing really in the model all the data is coming into the Collection via an external url call to a json file that is build from a database. So whats the purpose of the model? I am sure that I am

How do I implement the Backbone model in latest Parse js sdk (1.6.2)?

。_饼干妹妹 提交于 2019-12-18 08:46:10
问题 The Parse Collection class corresponding to Backbone.Collection is no more in the SDK. It used to be there in 1.2.13. 回答1: As of September 9th, 2015, the Parse Javascript SDK no longer contains backbone specific behavior. You can reference a previous version of the JS SDK (http://www.parsecdn.com/js/parse-1.5.0.min.js) to access the backbone specific behaviors but understand that branch is no longer maintained. V1.6.0 — SEPTEMBER 9, 2015 New Features Designed to work with ES6. Parse.Object

How to find a model from a collection according to some attribute other than the ID?

▼魔方 西西 提交于 2019-12-17 17:36:48
问题 I have a model with several object: //Model Friend = Backbone.Model.extend({ //Create a model to hold friend attribute name: null, }); //objects var f1 = new Friend({ name: "Lee" }); var f2 = new Friend({ name: "David"}); var f3 = new Friend({ name: "Lynn"}); and also, I will add these friends object to a collection: //Collection Friends = Backbone.Collection.extend({ model: Friend, }); Friends.add(f1); Friends.add(f2); Friends.add(f3); and now I want to get a model according to the name of

Feed backbone collection with multiple different model classes

时间秒杀一切 提交于 2019-12-14 02:21:43
问题 I have several models which have their own url/api they can fetch. I would like to keep them in a collection. does it sound like a good idea? how would you fetch them? (I'm thinking just to get the model I want to update from the collection then fetch it) Let me know what you think, if you have any theoretical reading/advise. 回答1: A collection can contain any raw objects or any models derived from a Backbone.Model . Fetching a collection makes sense only if you have an API endpoint which

Backbone.js - base path not concat with subpaths

巧了我就是萌 提交于 2019-12-13 08:34:54
问题 In my base collection i have the base path, from the base path i am extending further urls.. but while i console the url in the extended collection i am not getting the full path of the url.. instead just i am getting the url - what the extended collection have.. why i am getting like so, and what should be the proper approach? here is my try : BaseCollection = Backbone.Collection.extend({ path: 'http://path/to/api' }); TeachersCollection = BaseCollection.extend({ url:"xyz/abc", initialize

Add new collection to parent view from child view

孤者浪人 提交于 2019-12-13 07:20:52
问题 I have a parent view (which is for car engines) that contains a child view which displays a list of options. One of the options is to add a new collection to the parent view. My child view init function looks like this: initialize: function (engine) { this.engine = engine; //parent object this.valves = engine.valves; //may or may not be empty }; Then I have this method that adds the collection(valves) when a button is pressed: addPerformanceValves: function() { var self = this; if (this

Typescript type checking - Backbone.Model instance cannot be type checked

牧云@^-^@ 提交于 2019-12-12 16:04:12
问题 I'm having a problem with Typescript and Backbone collections. Here's some groundwork: class BaseChartModel extends Backbone.Model { } class ScatterPlotModel extends BaseChartModel { } class BarChartModel extends BaseChartModel { } class MixedChartCollection extends Backbone.Collection { public model: BaseChartModel; ... } class ScatterPlotCollection extends Backbone.Collection { public model: ScatterPlotModel; ... } class BarChartCollection extends Backbone.Collection { public model:

Backbone View not refreshing even when Collection gets Refreshed

一曲冷凌霜 提交于 2019-12-12 04:56:37
问题 I have a backbone collection that dynamically takes the URL to fetch results. I then create a view that has the key-up event to capture key input and refresh the collection from the back-end. I have added a listener to my view for collection change but that is not being triggered on my key-up event even though the collection is getting refreshed. employees.EmployeesCollection = Backbone.Collection.extend({ url: function() { if(this.searchName) return serviceUrls.employees_searchByName_url + "

Render a View of Backbone Model returns undefined

廉价感情. 提交于 2019-12-12 01:43:22
问题 Lets say i have a JSON like this: JSON example, my json is validated on jsonlint and it works. json_object = { "texts_model": { "hello": "hola", "icon_text": "Icon!" }, "collection_vias": { "text": "hola", "icon_text": "Icon!" } }; I have made a Collection that parse the contents of the json and generates model and collections from this json. App.TemplatesCollection = Backbone.Model.extend({ model: App.TemplateModel, url: TEMPLATES_SERVICE, initialize: function(){ this.fetch({ success: