marionette

What is the difference between url vs urlRoot

不问归期 提交于 2019-12-21 03:17:04
问题 I would like to know what is the difference between using url or urlRoot . I have read the documentation (backbonejs.org/#Model-url), but I still feel that I lack knowledge in this area and I would like to know more. When do you have to use url ? And in another instance when do you have to use urlRoot ? 回答1: .urlRoot is only available in a Model, and is only useful when either a model is not part of a collection, or when you want to override the .url property of the collection which that

Marionette ItemView how to re-render model on change

余生长醉 提交于 2019-12-20 12:07:15
问题 I'm using Handlebars template engine. so, I have Model: Backbone.Model.extend({ urlRoot: Config.urls.getClient, defaults: { contract:"", contractDate:"", companyTitle:"", contacts:[], tariff: new Tariff(), tariffs: [], remain:0, licenses:0, edo:"" }, initialize:function(){ this.fetch(); } }); then Marionette ItemView: Marionette.ItemView.extend({ template : templates.client, initialize: function () { this.model.on('change', this.render, this); }, onRender: function () { console.log(this.model

backbone.js collection view example using marionette template

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 10:43:33
问题 Can you please suggest me some example for showing list view through marionette template system. Basically, I have a marionette template and based on the template i am creating a table list. 回答1: To create a list of table rows with Backbone Marionette you'll need to define five things: A model for each row A collection to hold all the row models A CollectionView to iterate through the collection An ItemView to provide row-specific functionality A template for the ItemView that provides the

Backbone.Marionette vs Backbone-Boilerplate

淺唱寂寞╮ 提交于 2019-12-20 10:39:09
问题 I'm new to Backbone and trying to decide how to approach development. At the moment I'm wondering when people would use backbone.marionette over backbone-boilerplate? From what I can tell Marionette is a lot more prescriptive, but is this the way that most people approach development here? 回答1: Marionette automates a lot of housekeeping work with respect to views that I believe Backbone should've included in the first place. Marionette is actively maintained and found it to be extremely

Backbone.Marionette Fade Transition for only specific regions?

假装没事ソ 提交于 2019-12-20 10:08:44
问题 I know I can override all regions to add a fade transition by using the following. Marionette.Region.prototype.open = function(view){ this.$el.hide(); this.$el.html(view.el); this.$el.fadeIn() } Is there a way to only override specific regions or views? I have certain regions in my layout that I would like to be able to fade in while other regions should be rendered instantly. Thanks, dk 回答1: You can define a custom Region the way you can define any Backbone object, and add this code to that

Backbone.Marionette Fade Transition for only specific regions?

柔情痞子 提交于 2019-12-20 10:07:37
问题 I know I can override all regions to add a fade transition by using the following. Marionette.Region.prototype.open = function(view){ this.$el.hide(); this.$el.html(view.el); this.$el.fadeIn() } Is there a way to only override specific regions or views? I have certain regions in my layout that I would like to be able to fade in while other regions should be rendered instantly. Thanks, dk 回答1: You can define a custom Region the way you can define any Backbone object, and add this code to that

Debugging Javascript (Backbone and Marionette)

久未见 提交于 2019-12-20 09:19:39
问题 Right now, while I am debugging backbone or marionette using the chrome dev tools, I end up setting break points and whatnot, but once the code pauses, its hard to tell what type of objects i'm working with because chrome labels everything a "child". (I think because that's the constructor function) Is there any easy way to either change this declaration or determine which type of model/collection i'm using. The amount craziness this causes in me wants to start doing something like this:

Use Handlebars.js with Backbone.Marionette

痞子三分冷 提交于 2019-12-20 09:01:31
问题 Is it possible to use the Handlebars.js with the Backbone.Marionette extension without reimplementing the Views render function? It seems that Marionette is relying on the convention that you use Backbone.js with underscores templating engine. But I really like the handlebar approach so I'm asking if I can the high-level-tools of Marionette with handlebars. 回答1: A simple way to use Handlebars with Marionette is simply to define template in each View as a pre-compiled Handlebars template

Backbone Marionette Region show without render

柔情痞子 提交于 2019-12-20 06:19:14
问题 Is it possible to put a view that is already rendered into a backbone marionette region without rendering it again? For example: region.show(myView); // This will call render on myView I don't want the region to render my view again. If I do: region.attachView(myView); // This won't render myView, but it also won't show it 回答1: First override marionette ItemView constructor and render like this (if you want to use it in CollectionView and CompositeView override these methods of them too): var

Backbone/Marionette ItemView not rendering on model change

∥☆過路亽.° 提交于 2019-12-20 04:39:09
问题 Already a couple of hours struggle trying to solve this... Although the model gets fetched correctly and I can verify it as the view gets informed of the model's 'change' event, it just does not render. At startup, the default model data ('Test Project'), is correctly displayed in the view, but after the model is refreshed, the view is not refreshed. I tried to show a new view in the layout after model refresh but it did not change much... Any idea or opinion about this ? App.Project =