This is for backbone.js questions that specifically relate to Backbone's event handling system.
Questions tagged [backbone-events]
787 questions
16
votes
2 answers
Backbone event firing on click OR press enter
I am new to backbone and I am looking for a way for my button to be triggered when I press Enter as well as clicking. Currently showPrompt only executes on a click. What is the cleanest DRYest way to have it execute on pressing Enter as well,…

Melbourne2991
- 11,707
- 12
- 44
- 82
15
votes
3 answers
How do I get backbone to bind the submit event to a form?
I'm using the following code to create the view:
LoginForm = Backbone.View.extend({
tagName :"form"
,id : "login-form"
,className :"navbar-form"
,initialize: function () {
this.model = new StackMob.User();
…

Jim Barrows
- 3,634
- 1
- 25
- 36
14
votes
1 answer
Backbone.js - using trigger to trigger event and pass data
I'm writing a tab menu component using backbone.js as an MVC framework. When a user clicks on a tab, the component will switch tabs (internal operation), but then I would like listeners of the component to respond to the action associated with the…

Brendan Delumpa
- 1,155
- 1
- 6
- 11
14
votes
1 answer
How to get attributes from the clicked element in backbone event?
Here is my basic backbone view for changing routes. I would like to get the href attribute of the clicked link. How to do that? Here is a code bellow:
var Menu = Backbone.View.extend({
el: '.nav',
events: {
'click a'…

hjuster
- 3,985
- 9
- 34
- 51
14
votes
2 answers
Passing arguments to events in backbone
First of all, I did some search and no answer on stackoverflow/google provided me the thing I wanted.
Here's a snippet of my code:
//in the view
this.collection.on("add",triggerthis)
this.collection.add(predefinedModel)
triggerthis: function(a, b,…

chenglou
- 3,640
- 2
- 25
- 33
13
votes
1 answer
Backbone. Dispatch/listen to events between views
Im a bit confused over how to handle events between views in Backbone. Right now i have two partial views rendered at the same time on a website. Now i want one of the views to dispatch an event that the other view can listen to. How would i do…

user3122094
- 241
- 1
- 2
- 15
12
votes
2 answers
How do I add a resize event to the window in a view using Backbone?
I have been trying to attach a handler to the resize event in one of my Backbone views. After doing some research I have discovered that you can only attach events to the view's element or its descendants.
This is an issue for me because the visual…

Eli
- 369
- 1
- 5
- 12
12
votes
1 answer
backbone.js events and el
Okay, so I've read several other questions regarding Backbone views and events not being fired, however I'm still not getting it sadly. I been messing with Backbone for about a day, so I'm sure I'm missing something basic. Here's a jsfiddle with…

siyegen
- 123
- 1
- 1
- 5
12
votes
1 answer
{silent:true} in Backbone 1.0 version
I was updating my backbone version from 0.9.2 to 1.0 yet I've encountered a problem.
The model is not updating properly. It has delays in it. previously my code below works perfectly:
this.model({ attrib: true},{silent:true});
But after updating I…

n0minal
- 3,195
- 9
- 46
- 71
11
votes
1 answer
Using backbonejs view, what is the best way to attach an "onload" event to an image tag?
I want to attach an "onload" event for an image in a backbonejs view. I am currently including it in the "events" as "load img":"function", but it is not getting fired off.
Any suggestions for doing this?

KD12
- 421
- 1
- 5
- 15
11
votes
2 answers
How to capture the key event from a view?
I'm trying to capture the key event from a view as follows:
myView = Backbone.View.extend({
el: $('#someDiv'),
initialize: function(){
// initialize some subviews
},
render: function(){
return this;
},
events:{
'keypress…

Running Turtle
- 12,360
- 20
- 55
- 73
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
3 answers
Bind backbone event to a multiple class selector
I can't get the following event to attach to my element.
events = {
"change .date-selector .date-range": "dateRangeSelectionChanged"
}
Is this supported at all in Backbone.js? Or am I using a wrong syntax?

orad
- 15,272
- 23
- 77
- 113
11
votes
1 answer
How can I "bubble up" events on nested Backbone collections?
I have a Backbone app that uses nested collections (at least that's how I think they're called).
In my particular case there are tabs and subtabs, and each tab (model) contains a collection of subtab (model).
For those who're more familiar with…

Chris X
- 901
- 3
- 9
- 19
11
votes
4 answers
How to know when a Backbone model.fetch() completes?
I bind on the change event of my backbone models like this.
this.model.on( "change", this.render, this );
Sometimes I want to fetch the latest version of the model and forcibly render the view. So I do this
this.model.fetch();
Unfortunately…

user1031947
- 6,294
- 16
- 55
- 88