Questions tagged [backbone-views]

Views in the Backbone.js library. Backbone views are used to reflect what your applications' data models look like. They are also used to listen to events and react accordingly.

Docs

1114 questions
12
votes
2 answers

Error while creating a backbone.js view - Expecting a function in instanceof check, but got [object Object]

I am trying to create a simple backbone.js view with the following code:
user700284
  • 13,540
  • 8
  • 40
  • 74
11
votes
3 answers

Backbone partial view not rendering the latest model

I am relatively new to Backbone and I am running into this problem. I am using Backbone with DustJS My template looks something like this - index.dust
{>"app/inc/responseMessage" /}
suprita shankar
  • 1,554
  • 2
  • 16
  • 47
11
votes
1 answer

Backbone.js _ensureElement error

I'm getting this error, when I want to initialize the view from router class. Error is: Uncaught TypeError: Object # has no method '_ensureElement' BlogFormView: App.BlogFormView = Backbone.View.extend({ el: ".data-form", initialize:…
11
votes
1 answer

Backbone Custom Events

Let's say I have two views (paginationview and postsview) and a collection (postscollection). Whenever the .next button is clicked in the paginationview I am calling the next function in the postscollection and the post collection is fetching the…
s_curry_s
  • 3,332
  • 9
  • 32
  • 47
11
votes
1 answer

Backbone table view consuming row view - how to structure?

I have a collection of models that I wish to render in a table view. Each model should be represented by a single row in the table, and this row should be generated using a template. I should be able to attach event handlers to that row (say click),…
oli
  • 3,541
  • 1
  • 27
  • 34
10
votes
4 answers

How can I dynamically set a className for a Backbone.js view based on it's model attributes?

Basically what I need is to do something like this App.CommentView = Backbone.View.extend({ className: function() { if (this.model.get('parent_id')) { return 'comment comment-reply'; } else { return 'comment'; } }, The…
Jakub Arnold
  • 85,596
  • 89
  • 230
  • 327
10
votes
4 answers

Backbone model state when tied to a form

I'm building a form with Backbone and looking to have it validate its fields on the "blur" event. Hooking into the event is easy enough, but what I'm curious about is whether or not the model should be updated on blur or only when the form is…
jbarreiros
  • 1,103
  • 1
  • 10
  • 21
9
votes
5 answers

Marionette bubble event from itemview to parent layoutview?

I have a layout view with a region, in that region I have a item view that triggers an event but it doesn't seem to be bubbled up to the layout view. Am I doing something wrong or is this designed behavior? I assume the itemview prefix is not…
Jon
  • 4,295
  • 6
  • 47
  • 56
9
votes
5 answers

Backbone Marionette, Composite View initializes twice

I'm using a composite view that has $.dialog called on it's $el. The composite view is then listing items from a collection. Now i've tried multiple ways to render the collection items: fetching from outside the composite view before and after…
9
votes
3 answers

In Backbone this.model is undefined, why?

I've looked everywhere for an answer but wasn't satisfied with what I've found. The issue is, I'm doing a tutorial from Addy Osmani to make a 'Todo' app in Backbone, but when I look at the console, I get an error saying that this.model is…
Shaoz
  • 10,573
  • 26
  • 72
  • 100
9
votes
1 answer

wordpress 3.5 media manager - add my own backbone.js views

I am currently trying to utilize the new WordPress 3.5 media manager which uses backbone.js to create and populate its modal window. What I want to do is: a user clicks upload button, media manager pops up, user selects image, presses insert, image…
Kriesi
  • 141
  • 1
  • 9
9
votes
4 answers

Is using the same id multiple times on a page bad practice even when I am not parsing through the page?

I understand that using the same id multiple times in a page creates malformed html. When using a jquery selector only the first element with the id will be returned, but in my application I shouldn't be running into this issue. I have list of items…
user1473339
9
votes
1 answer

How to create a base view in backbone.js?

I need to create a base view which all my views would extends. I'm not really sure where and when to declare this view. Basically, I need to inject global variables to all my templates and I don't do to that in each and every render() methods. this…
maxwell2022
  • 2,818
  • 5
  • 41
  • 60
8
votes
4 answers

How do I call a backbone view event only once?

I have a backbone view that looks like this: var myView = Backbone.view.extend({ events: {'click .myClass': 'myFunction'}, initialze: //initialize function, render: //render function, myFunction: function (e) { //do…
YPCrumble
  • 26,610
  • 23
  • 107
  • 172
8
votes
3 answers

Setting dynamic css-style properties of a Backbone.View

I'm trying to set the height, width and background image of a
    element. Here's what I've got for my Backbone.View: var RackView = Backbone.View.extend({ tagName: 'ul', className: 'rack unselectable', template:…
Sean Anderson
  • 27,963
  • 30
  • 126
  • 237
1
2
3
74 75