Questions tagged [marionette]

Backbone.Marionette is a composite application library for Backbone.js that aims to simplify the construction of large scale JavaScript applications. Do NOT use this tag for Firefox's Marionette driver. Use the firefox-marionette tag instead.

Backbone.Marionette is a collection of common design and implementation patterns found in the applications that we have been building with Backbone, and includes pieces inspired by composite application architectures, event-driven architectures, messaging architectures, and more.

Important to note that Marionette introduced some breaking changes in their API when moving from 1.X to 2.X below is a quick summary of the main breaking changes that can cause errors in your app, a full report on the changes can be found on google docs.

General

  • All instances of the word type in the API have been replaced with the word class. For instance:
    • regionType => regionClass
    • ChildViewType => ChildViewClass

Applications and Modules

  • Application’s initialize triggerMethods have been renamed to start, which is more descriptive of what is actually happening. More specifically, initialize:before and initialize:after are now before:start and start, respectively. Note that no functionality has been lost with this change; it is merely a changing of names.

Controllers

  • close has been renamed to destroy to emphasize the fact that an instance should not be reused, or ‘opened,’ after it is destroyed

Regions

  • Regions now expose region.el and region.$el, just like View’s. Due to this change if you were depending on region.el to be a string selector you must update your code to use region.$el.selector.

  • The open method has been renamed to attachHtml

Views

  • Layout is now called LayoutView
  • Renamed close to destroy for views. Close was a confusing verb for users who thought that they could be reopened. The verb destroy makes it more clear that once a view is destroyed you can not reuse it.
  • Returning false from onBeforeClose no longer prevents the view from closing
  • appendHtml has been renamed to attachHtml.
  • appendBuffer has been renamed to attachBuffer
  • Removes duplicate and inconsistent itemView events. No functionality was lost with this change; simply use the unprefixed version instead. For instance, use before:render instead of item:before:render
  • childEvents callbacks no longer receives the event name as the first argument
  • itemView within a collectionView is now known as childView. This removes confusion for new users as to the fact that you can show any type of view in your collectionView.
  • All CollectionView methods that referenced itemView now use the same childView as well. For instance, getItemView is now getChildView. Do note that CompositeViews extend from CollectionView, so these API changes affect that Class as well.

References

2383 questions
0
votes
1 answer

retrieve URL parameters to pre select multi select list - marionette

I'm fairly new to Marionette. I've a router that passes parameters. The template has few check boxes, radio button and a multi select list. When the template is rended, the checkbox and radio button behaves as per the parameter values. Im trying to…
azuka
  • 65
  • 1
  • 9
0
votes
1 answer

Spying/testing if trigger on event handler works using Chai

I'm very new to Chai testing. I can't find good example. Basically, what I want to happen is check wether the event got triggered. on my patientInfo.js, the code to trigger the event is import PatientBus from 'backbone.radio'; patientAdded() { …
devwannabe
  • 3,160
  • 8
  • 42
  • 79
0
votes
1 answer

Marionette: setting collection after render doesn't update on model add

I have a nested composite view that checks its model for a collection, and if so sets that collection to itself as its collection. onRender: -> if model.attributes.has_collection @collection = model.get 'myCollection' This works quite well…
jacob.mccrumb
  • 681
  • 5
  • 18
0
votes
1 answer

before/after route method with Marionette AppRouter

In Backbone Router there is a chance to use before/after methods to define what's going to happen before/after the route get fired. I'm using Marionette AppRouter and I discover I cannot do the same with it. Do you know any way to reproduce the same…
0
votes
0 answers

Re-Rendering view by its id which backbone generates

I had a Marionette Item view which has rendered in two places of the page. Lets take an example like Foreign Address and Local Address. As the fields are same for both the things we had used the same view just the change in header label. We had…
CNKR
  • 568
  • 5
  • 19
0
votes
1 answer

Switching views within a Marionette region

I have a region in my Marionette project called the "primary" region for which I show a loading view and then a download view once the loading (decrypting) is finished. Here's what I have it doing right now: var loadingView = new…
chadb768
  • 473
  • 1
  • 8
  • 16
0
votes
1 answer

Using Backbone.js how i can ensure that all the app is loaded before any user interaction

I have a web page that was developed using Backbonejs and Marionettejs. I have a lot of views, the problem is when i enter for the first time to the app or i reload the webpage if i interact (make any click) in the page i think the page stops…
shau
  • 145
  • 2
  • 11
0
votes
2 answers

Looking for render event in delegateEvents in Backbone.View

I have one question about Backbone.View and its delegateEvents. You can read in docs here about extend method. Using this method, you can "override the render function, specify your declarative events" etc. I have a question about declarative…
Ish Thomas
  • 2,270
  • 2
  • 27
  • 57
0
votes
2 answers

Marionette.ItemView render event

It's hard to me to explain what I'm looking for, so I will start with code. I have Marionette view like this: Marionette.ItemView.extend({ model: new Models.Cards(), template: 'poker/cards', events: { 'click player':…
0
votes
1 answer

Single Page App - keep pages (views) in the DOM or not?

I am building a mobile web app and thinking of the best approach to manage the app pages (say 'full screen views'). When using jQuery Mobile, the heavily used pages are all kept in the DOM. Some other framework (Backbone/Marionette) users suggest…
Kazlauskis
  • 141
  • 1
  • 8
0
votes
1 answer

Marionette.js collection is undefined in collection view

I am fairly new with Marionette.js and seem to be having some trouble rendering a Collection View. I am receiving the following console error message when trying to show the view: Uncaught TypeError: Cannot read property 'toJSON' of undefined. It…
user2232681
  • 839
  • 4
  • 16
  • 33
0
votes
1 answer

model data is fetching after rending the view

I had a model and view, where view is rendering before the model is fetching the data. When i checked in the DB, the value is persisting to DB when i make changes in the view. But I am unable to get the value through model.fetch() while view is…
CNKR
  • 568
  • 5
  • 19
0
votes
1 answer

How to run toJSON on object from updated collection in Marionette ItemView?

I have created a custom object containing models within a collection, when I pick this object up in the ItemView as this.options.unique I can't run .toJSON as I get an error saying Uncaught TypeError: this.options.unique.toJSON is not a function.…
styler
  • 15,779
  • 23
  • 81
  • 135
0
votes
1 answer

Marionette router does nothing even if backbone history is started

I work on an app with Marionette and browserify. When I start my application, any routes is matched. My app code : app.js : var App = require('./App/SaApp.js'); App.start(); SaApp.js : var Mn = require('backbone.marionette'); var DashboardRouter…
amiceli
  • 437
  • 5
  • 11
  • 29
0
votes
2 answers

Marionette ItemView and radio Buttons

I have data being returned from a server with a status flag. And on each ItemView I have some radio Buttons as follows:
Linda Keating
  • 2,215
  • 7
  • 31
  • 63