backbone-views

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

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

Backbone.js - change not triggering while the name change

点点圈 提交于 2020-01-11 14:47:47
问题 In my backbone function, while the name get change the change function not at all triggering.. any one suggest me the right way to get it.. (actually i need to get changed stuff and need to update); code : (function($){ var list = {}; list.model = Backbone.Model.extend({ defaults:{ name:'need the name' }, initialize:function(){ this.bind('change:name', function(model) { console.log('Model->change()', model); }); } }); list.collect = Backbone.Collection.extend({ model:list.model, url : 'data

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:

Loading collections into models in backbone.js

六眼飞鱼酱① 提交于 2020-01-06 15:07:29
问题 Here's the goal: I have a parent model. It is in a collection called parents . In a parent is a collection of children . So, when I instantiate the parents collection, I get the parent models, each with the collection of children in them. I've tried doing this several different ways, and I'm getting different performance. Sometimes the children don't show up at all. Sometimes, they are repeated for each iteration of the parent render loop. I'm looking for help on what the best practice is for

Backbone Marionette Composite View Rendering

℡╲_俬逩灬. 提交于 2020-01-06 12:43:25
问题 Problem in short: Initializing a composite view in marionette with a collection of size ~500 stalls the app for around a minute. I'm building a backbone marionette app to maintain a list of items. When testing with a collection size of ~50 everything is fine. When the limit grows, app goes unresponsive. Store.ItemsListView = Marionette.CompositeView.extend({ tagName: "div", template: "#items-list", itemView: Store.ItemView, itemViewContainer: "tbody", emptyView: Store.NoDataView, }); Store

Backbone: How to trigger methods in a parent view

南楼画角 提交于 2020-01-04 04:22:27
问题 I have an alphabet filter view (a, b, c, d etc) that a lot of views will be using. I have setup a method on the main view to fetch results from the API using the letter clicked. I've setup this by passing a callback function down to the alphabet filter as per below: view = new App.Views.Common.AlphabetFiltersIndexView(filterCallback: @paginationFilter) @$(".pagination-vertical").replaceWith(view.render().el) Calling the filterCallback and passing arguments works, however the paginationFilter

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 and where to initialize jquery datatable in backbone view

和自甴很熟 提交于 2020-01-01 11:48:12
问题 My html template look like this: <script type="text/template" id="players-template"> <table id="example" class="table table-striped table-bordered table-condensed table-hover"> <thead> <tr> <th>Name</th> <th>group</th> <th></th> </tr> </thead> <tbody id="playersTable"></tbody> </table> </script> <script type="text/template" id="player-list-item-template"> <td><@= name @></td> <td> <@ _.each(hroups, function(group) { @> <@= group.role @> <@ }); @> </td> </script> My backbone view is as follows

Understanding Backbone and Marionette View lifecycle

泄露秘密 提交于 2020-01-01 09:08:07
问题 I'm new to this world and I need to understand some of the concepts of Backbone and Marionette. Here I'm trying to explain some of the concepts I'm learning. It would be great to having some feedback on them. The render function defines the logic for rendering a template. When it is finished, the onRender callback is called. Here I suppose the rendered view has been not attached to the DOM. It is composed by a tagName (the default is div ) that contains the template I attached to it. To