marionette

How to access a composite view from an item view instance in Backbone Marionette

天涯浪子 提交于 2019-12-03 02:20:19
问题 The basic situation is this: I have a Composite View and an Item View. I construct the Composite view passing it a model and a collection. The model data is used to populate the template for the Composite view. The collection data is used to populate the Item View for the Composite View. What I want to do is this: in a template helper for the Item view I want to access the model data for the Composite View. I've got as far as accessing the view instance of the Item View. I thought that might

What's the difference between a Marionette Layout and a Region?

对着背影说爱祢 提交于 2019-12-03 00:09:18
问题 Marionette provides two components named Regions and Layouts. At first glance, they seem to provide similar functionality: A location on the page for my application to place subviews, plus some additional event binding fairy dust. Looking under the hood, it's fairly clear that each component is implemented in a very different way, but I'm not sure why and when I would want to use one over the other. What use cases are each component intended for? 回答1: Layouts and Regions serve very different

Using Marionette.ItemView for views without models?

荒凉一梦 提交于 2019-12-02 23:50:46
Is it conventional to use Marionette.ItemView for view classes that do not have a specific model property associated with them? As Marionette.View is not meant to be used directly, it seems like an ItemView makes sense as a view class with convenient defaults and bindings. Or, should one just resort to using Backbone.View ? If so, is there a way to hook Backbone.View into Marionette's evented and garbage-collected architecture? Thank you for clarification! ItemView can be used without a model. I do this quite regularly. If you need to specify data for an ItemView, but not have that data in a

Backbone.Marionette vs Backbone-Boilerplate

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 23:34:34
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? 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 useful and flexible for my project. backbone-boilerplate, from what I see, is more of a way to organize your code

backbone.js collection view example using marionette template

主宰稳场 提交于 2019-12-02 22:48:17
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. seebiscuit 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 markup for each row Sample Use Case Say you have the following data: var stooges = [{ name: 'moe',

Backbone.Marionette Fade Transition for only specific regions?

冷暖自知 提交于 2019-12-02 21:06:00
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 Derick Bailey You can define a custom Region the way you can define any Backbone object, and add this code to that region type. MyRegion = Backbone.Marionette.Region.extend({ el: "#some-element", open:

How to use Backbone.Marionette.ItemView with Mustache

落爺英雄遲暮 提交于 2019-12-02 18:36:42
The following code works fine using Backbone.Marionette.ItemView but not Mustache . Backbone.Marionette.ItemView - no Mustache I would like to use the same code but loading the template varaible using Mustache . Here is my code: Backbone.Marionette.ItemView - with Mustache Any idea why my code does not work and why? Thanks Marionette assumes the use of UnderscoreJS templates by default. Simply replacing the template configuration for a view isn't enough. You also need to replace how the rendering process works. In your simple example, you only need to override the Marionette.Renderer.render

Debugging Javascript (Backbone and Marionette)

安稳与你 提交于 2019-12-02 18:23:54
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: MyModel = Backbone.Model.Extend({ // the $$$ puts it at the top of the inspector, the NAME is just for

Can't seem to cleanup detached DOM elements

五迷三道 提交于 2019-12-02 18:22:01
I'm using jquery-ui Tabs and I'm having a problem that occurs when a tab has been removed. The tab appears to be removed, along with its content div but when you take a look at the heap in Chrome DevTools Profiles (after a tab has been removed) you'll see that the tab li and div elements are still present, but detached. Over time, the repeated addition/removal of tabs causes these elements to accumulate. For example, if you add a tab 10 times, there will be 10 detached div elements and 10 detached li elements showing up in the heap snapshot: I have the following views: TabLabel = Marionette

backbone.marionette + i18n + handlebars

荒凉一梦 提交于 2019-12-02 17:47:59
Can some one post an example of combining these libraries together? including the handler for the i18n and marionette. Thanks point backbone.marionette templates to compile hendlebars. this can be done on your main.js: Backbone.Marionette.TemplateCache.prototype.compileTemplate = function(rawTemplate) { return Handlebars.compile(rawTemplate); }; configure your app to use handlebars and i18n: this can be done on your config.js: require.config({ // Initialize the application with the main application file deps: ["main"], paths: { libs: "../assets/js/libs", plugins: "../assets/js/plugins", //