marionette

Use Handlebars.js with Backbone.Marionette

做~自己de王妃 提交于 2019-12-02 17:39:36
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. brettjonesdev A simple way to use Handlebars with Marionette is simply to define template in each View as a pre-compiled Handlebars template function. For instance: var MyView = Backbone.Marionette.ItemView.extend({ template: Handlebars

Marionette CompositeView children.findByIndex not working as expected after collection sync

流过昼夜 提交于 2019-12-02 17:15:05
问题 I have the following code that happens after a collection sync: adGeneration: function() { var child = this.children.findByIndex(this.children.length - 1); console.log(child.model.toJSON()); eventer.trigger('generate:new:ad', child); }, The problem I am running into, is that, after the first sync, the child element is a blank model: First Time: Object {id: "5-vp39kv3uiigxecdi", size: 26, price: "9.84", face: "( ⚆ _ ⚆ )"} Every time after: Object {length: 40, models: Array[41], _byId: Object,

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

让人想犯罪 __ 提交于 2019-12-02 15:50:38
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 give me a handle on the Composite View, from where I could get to its model, but it doesn't. Is there a

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

岁酱吖の 提交于 2019-12-02 13:54:16
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? Layouts and Regions serve very different purposes: a layout is a type of view, but a region will display a view in your HTML/DOM for you. A region

Backbone Marionette Region show without render

一笑奈何 提交于 2019-12-02 10:24:46
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 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 fnCons = Marionette.ItemView.prototype.constructor, fnRender = Marionette.ItemView.prototype.render;

Backbone/Marionette ItemView not rendering on model change

谁说我不能喝 提交于 2019-12-02 03:22:26
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 = function () { var Project = {}; var ProjectModel = Backbone.Model.extend({ defaults:{ id: 0, name: "Test

how to load html file in Marionette .js + backbone?

假如想象 提交于 2019-12-02 03:19:28
I have one "test.html" in that I have this contend (whole html file have this contend). <h1>First page</h1> I need to load that contend in my div having id ="contend" using Marionette .js <div id="contend"> </div> could you please tell me how I will do that ? fiddle : http://jsfiddle.net/JQu5Q/16/ $(document).ready(function(){ var ContactManager = new Marionette.Application(); ContactManager.addRegions({ mainRegion:"#contend" }) ContactManager.on("start", function(){ console.log("ContactManager has started!"); }); ContactManager.start(); // router var routers = Backbone.Router.extend({ routes:

Marionette.js with Rails (Devise) Authentication

馋奶兔 提交于 2019-12-01 21:40:21
Curious as to how people usually handle this. My strategy is to have an authorized root route and unauthorized root route. The authorized users get sent directly to my marionette.js single page application and unauthroized users get sent into a standard rails landing page with the option to login or register. It seems you could combine these all into your single page application. You could show/hide ui elements based on a class you attach to elements based on the authorization needed to see them (registered, admin, moderator, etc). You could also add some kind of "before_filter" to your router

Capture scroll event on div

心不动则不痛 提交于 2019-12-01 19:36:12
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': 'loadMoreBooks', 'click': 'loadMoreBooks' }, // some functions loadMoreBooks: function(){ console.log(

Creating a layout that accepts a variable number of views (and hence regions)

末鹿安然 提交于 2019-12-01 16:49:27
问题 My goal I need to create a custom layout (a flow layout) that can receive a variable numbers of views and based on them, it creates regions as necessary and within those regions it shows the views that are passed in. The views can be arranged vertically or horizontally. Requirement The layout has a template where initially regions are not defined. It only contains a wrapper ( data-role="region-wrapper" ) where added regions will be rendered. My approach. 1 - Extend a Marionette.Layout