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
6
votes
4 answers

How to pass arguments to functions binded in events object in backbone.js

I need to have arguments to the functions used in the events object in Backbone. var DocumentRow = Backbone.View.extend({ tagName: "li", className: "document-row", events: { "click .icon": "open", "click .button.edit":…
Gautham Renganathan
  • 647
  • 1
  • 9
  • 18
6
votes
3 answers

how to access a models data from a view in backbone.js

I have a model named person: var person = Backbone.Model.extend({ initialize: function(){ console.log('cool'); }, defaults:{ names:['a','k','d','s','h','t'] } }) Now I have a view: var person_view =…
Wern Ancheta
  • 22,397
  • 38
  • 100
  • 139
6
votes
1 answer

How do you dynamically create Backbone view elements?

I'd like to create some view elements in a Backbone js application dynamically. When a new view is initialized, I want it to insert the new element into the DOM, store the reference to the element in view.el, and delegate events as usual. I…
chrisM
  • 338
  • 1
  • 4
  • 9
5
votes
1 answer

Preventing backbone zombie views

Note: we are using backbone 1.0.0 I am relatively new to Backbone, and was going to through some of the code a ex co-worker wrote. Rather than copy pasting stuff blindly, I wanted to understand how he did things, and that's when I started wondering…
iDesi
  • 692
  • 1
  • 10
  • 19
5
votes
1 answer

how to delegate a "load" DOM event?

I would like to call a function when a "load" event is triggered: events: { "load #eventPicture" : "_resizeHeaderPic" } I don't want to do something like this.$("#eventPicture").on("load", _resizeHeaderPic); because I have a lot of views (it's…
Bertuz
  • 2,390
  • 3
  • 25
  • 50
5
votes
1 answer

backbone click events not firing

I am not sure why this is happening. This looks very unusual to me. Generally when i want an action to be performed on a button click i will use this events:{ 'click #button_name':'somefunction' }, somefunction: function(){ alert("Blah"); } But…
seshan
  • 99
  • 2
  • 11
5
votes
2 answers

Proper way to create a collection list view in Backbone

I'm currently learning Backbone.js and I'm having a hard time learning how to properly use Views (since I have experienced when it comes to MVC), so here is what I'm trying to do: templates: