backbone-events

Bind a view to collections in backbone.js

|▌冷眼眸甩不掉的悲伤 提交于 2020-03-22 08:51:10
问题 I'm semi-new to backbone. I'm trying to bind a collection to a view so that when a new model is added to a collection, the view is updated. I think when you do this with models you can bind to the model's change event. But how do you do the same with collections? App.Views.Hotels = Backbone.View.extend({ tagName: 'ul', render: function() { this.collection.each(this.addOne, this); var floorplanView = new App.Views.Floorplans({collection:floorplanCollection}); $('.floorplans').html

Backbone router creates multiple views which causes multiple events to bind to the same view

*爱你&永不变心* 提交于 2020-01-24 21:15:30
问题 I'm new to backbone.js and trying to understand how routes, views etc works and now I have a problem with events building up for the same view. here is a clip that will show you exactly what I mean. http://screencast.com/t/QIGNpeT2OUWu This is how my backbone router looks like var Router = Backbone.Router.extend({ routes: { "pages": "pages", } pages: function () { var page_view = new PageView(); } }); So when I click the Pages link I create a new PageView and this is the code I'm using

binding events to dynamic objects in underscore/backbone

风格不统一 提交于 2020-01-16 04:21:29
问题 I'm trying to figure out how to listen for custom events on objects which have not been prototyped or are not dom objects in underscore.js/backbone.js. for example: //this is inside a view object play: function(arg) { this.a = this.image(this.model.a); this.a.bind("ready",start,this);//<--- causes error this.b = this.image(this.model.b); this.b.bind("ready",start,this);//<--- causes error function start() { // do some stuff in here } //some more stuff }, image: function(args) { // load the

Typescript Backbone View Events do not fire

感情迁移 提交于 2020-01-14 01:40:25
问题 I'm trying to make a simple view to test with backbone. I've started with events, but no one fires. Why ? I've made already other things with backbone like routing etc. without problems. Thanks for your time. My backbone definitions are from -> this source <- module Views { export class MenuView extends Backbone.View { constructor(viewOptions?: Backbone.ViewOptions) { super(viewOptions); } el = document.body; events = { "click #Btn-Start": "navigate", "click #Btn-Software": "navigate", "click

Capture scroll event on div

让人想犯罪 __ 提交于 2020-01-11 09:24:27
问题 I'm trying to capture the scroll event within a Backbone.Marionette.CompositeView, but without success. As an exercise, I'm rewriting http://www.atinux.fr/backbone-books/ using Backbone.Marionette. As you can see, when you scroll down, more books are fetched and displayed (i.e. infinite scroll). However, I'm unable to capture the scroll event on my view. Here's my (simplified) code: LibraryView = Backbone.Marionette.CompositeView.extend({ // properties, initializer, etc. events: { 'scroll':

How to enable/disable save button of backbone form-view when user changes form content

痞子三分冷 提交于 2020-01-06 18:03:55
问题 I have form which gets data from backbone model. When the form is shown, they have initially value set to backbone model. Now, if any field is edited, i want to enable "save" button immediately as soon as any changes is made to field. However, if you change field value and again change it to original, it should again disable the "save" button that allows to save model.I want to achieve as one shown in this jsfiddle :http://jsfiddle.net/qaf4M/2/ I am using backbone.js and backbone.stick (http:

Hammer events delegation and reuse of backbone view

谁都会走 提交于 2020-01-04 03:57:04
问题 Edit According the Hammer Github page this bug was due to Manager leaks and should be fixed in the 2.0.5 version - this version is not built online but one can built it by himself. More info can be found here ===================================================== Original question: ===================================================== We are using Backbone with Hammer 2,backbone hammer plugin and hammer jquery plugin. The issue when working with domEvents and only 1 copy of A view it works

How can I “bubble up” events on nested Backbone collections?

∥☆過路亽.° 提交于 2019-12-30 17:22:20
问题 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 code, I'll write bellow my models and collections, and how subtabs are nested inside the tab model: // Subtab Model var Subtab = Backbone.Model.extend({ defaults: { label: undefined } }); // Subtabs Collection var Subtabs = Backbone.Collection.extend(

After Adding a record it is not displaying the data immediately to the view

三世轮回 提交于 2019-12-25 03:58:18
问题 When I loads the page , it is getting all the datas and I am displaying the datas. But When I add a record, that is I am submitting the form "addcontact", the datas are creating in the database. But It is not adding into the collection and that this.collection.on('add') is not getting triggered. So, I think the problem was because of this. Can any one tell me that where I am doing wrong? Is there any other way to solve this. This code works functionally, but the only problem with this is , on

Access click event outside the el in backbone view

人走茶凉 提交于 2019-12-23 13:24:07
问题 How can i access click event outside the el scope. What i have : HTML : <div class="right_btn"></div> <div id="template_loader"> <!-- HTML template goes here which contain form inputs--> <input type="text" class="forgot_password_email" name="forgot_password_email"/> </div> View : var ForgotPasswordView = Backbone.View.extend({ el: "#template_loader", initialize: function () { console.log('Forgot Password View Initialized'); }, render: function () { blockPage(); var that = this; $.get(App