Marionette's view can't be inserted in Backbone.Modal

205 Views Asked by At

I tried to use this backbone extension for making stackable modals.

http://awkward.github.io/backbone.modal/

It says is compatible with Marionette and so i been trying to use it with views that i create with it. But the problem it seems that it doesn't allow me to use eco templates and the examples in the website are only with underscore templates.

For declaring Marionette views using eco templates all i need to do is this :

class Views.ItemView extends Marionette.ItemView
  template: "items/show/templates/item"

But i can't define the template that way for the Backbone.Modal view class, also i can't pass a view into the template and i tried to use the views stackable part but i'm very lost with it.

Thanks for your time and answer.

1

There are 1 best solutions below

0
On

If you're wanting to use eco templates with Marionette you'll need to do something like this before your views and after Marionette:

Backbone.Marionette.Renderer.render = (template, data) ->
  throw "Template #{template} not found" if !JST[template]
  JST[template](data)

The default template renderer assumes that the template is a function and just calls it with the output of serializeData and templateHelpers

If you don't want to define the custom renderer you should be able to change your template line to something like this:

class Views.ItemView extends Marionette.ItemView
  template: JST["items/show/templates/item"]