Questions tagged [backbone-model]

Models in the Backbone.js library.

Docs

325 questions
0
votes
2 answers

Different model types in one collection Backbone

Backbone 1.1.2 Underscore 1.7.0 jQuery 1.11.1 I have a single collection that holds messages. My messages can be be of different types (and the endpoints in the api are different for each type, but I have an endpoint that allows me to do one…
0
votes
1 answer

What is this.module and when do we use it in Backbone.js application?

Recently, I have started working on a project and in the code base I am finding lots of this.module statements (not this.model). As a beginner in backbone, I have no idea when should I use this and why? Any explanation would be really helpful.
Sharif Mamun
  • 3,508
  • 5
  • 32
  • 51
0
votes
1 answer

Backbone change event not firing when certain attributes are changed

In my backbone application, I have a model that looks a little like this, { "id" : 145, "name" : "Group Number 1", "information" : "Some kind of blurb about group number 1", "members" : {[ "id" : 1, "first_name" :…
Udders
  • 6,914
  • 24
  • 102
  • 194
0
votes
2 answers

Should Backbone Model represent a view or a server-side resource?

Assume a situation where I've a Rails AR models as below class User has_one :profile end class Profile belongs_to user has_one :address end class Address belongs_to :profile end And have a User Profile view to be constructed at the…
karthiks
  • 7,049
  • 7
  • 47
  • 62
0
votes
1 answer

Backbone model when created already has attributes

In my my application I do something like this to create a new model, this.model = new App.Models.Organisation; The code for the model looks like this, 'use strict' App.Models.Organisation = Backbone.Model.extend({ urlRoot: "http://" +…
Udders
  • 6,914
  • 24
  • 102
  • 194
0
votes
1 answer

Backbone running a method based on a collection listener

In my application have the following code, initialize: function() { Pops.Collections.TeamCollection = this.collection; this.collection.fetch(); this.collection.on('sync', this.render, this); }, render: function() { this.addAll(); …
Udders
  • 6,914
  • 24
  • 102
  • 194
0
votes
1 answer

Refer model from collection

I am using Backbone to structure my web application, this is my situation: Section = Backbone.Model.extend({ initialize: function(){ this.set("elements", new ElementCollection()); } }) ElementCollection =…
steo
  • 4,586
  • 2
  • 33
  • 64
0
votes
1 answer

Model attributes not getting set correctly after a fetch

In my model I have some nested collections, the API returns some data, and this gets parsed into a model fine, however because my API returned arrays in objects some of my attributes tend to look like this when logged... member: Array[2] In my model…
Udders
  • 6,914
  • 24
  • 102
  • 194
0
votes
1 answer

backbone collection get list of single attributes

I am wanting to get a list from my collection, the list will be used to add options to a select list. I am wanting to use this to filter the collection, So for example I am want filter my collection by the group attributes, so first I need to get…
Udders
  • 6,914
  • 24
  • 102
  • 194
0
votes
1 answer

BackboneJs application not rendering anything

Click here for the js fiddle example This template should render new messages in a collection, im trying to follow this tuorial with my own version that renders messages instead
user3531149
  • 1,519
  • 3
  • 30
  • 48
0
votes
1 answer

Search a collection for a models that have an attribute like and search param

I am wanting to search my collections for models that match closely to what the user is typing in to a search box, For example I have 3 models in a collection with each model has it's own name attribute and they are named as follows, 1) Apples Are…
Udders
  • 6,914
  • 24
  • 102
  • 194
0
votes
2 answers

Backbone Collection and Model url, bulk model collection save

I want to achieve. 1. Creating a single model on model.save should point to url mentioned in Models attributes 2. I want to do a bulk save ( how can i do that ). So, as per example, say I have arrays of books model and I want to save it at once…
Sami
  • 3,926
  • 1
  • 29
  • 42
0
votes
1 answer

Rails account_params missing parameters from backbone `.save()`

I am trying to create a user account using Backbone 1.1.2 and Rails 4.2.beta1. In backbone I am calling: public create(){ var email:string = $('#create-account-email').val(), password:string = $('#create-account-password').val(), passconf:string…
0
votes
2 answers

Backbone model.save() is causing OPTIONS not POST

I have a 'Create Account' view that I am starting to work on. Backbone 1.1.2 (typescript) front-end, Rails 4.2 beta 1 web service back-end. Account Model export class Account extends Backbone.Model { public urlRoot: string; public…
SnareChops
  • 13,175
  • 9
  • 69
  • 91
0
votes
2 answers

model validate in backbone.js

I have this simple script just to trying out the backbone validation functionality, but it doesn't seem to be working: Client = Backbone.Model.extend({ validate: function(attrs){ if (attrs.age < 18){ return console.log("Too…
Guille
  • 1
  • 1
  • 2