R
R
Roman Ogarkov2015-12-24 18:25:57
backbone.js
Roman Ogarkov, 2015-12-24 18:25:57

How to display View MarionetteJS?

There is a static view

define([
  'backbone.marionette',
  'hbs!templates/_layouts/_aside'
  ], 
function (Marionette, AsideView) {
  'use strict';
  return Backbone.Marionette.ItemView.extend({
    tagName: 'nav',
    id: 'main-nav',
    template: AsideView,
  });

});

There is main.js
require([
  'backbone.marionette',
  'domReady',
  'hbs!templates/index',
  'modules/statistics',
  'views/item/aside-view',
  'scripts/scroller',
  'scripts/app',
  ],
  function (Marionette, domReady, template, Statistics, AsideView, Scroller, App) {
    document.body.innerHTML = template(template);
    domReady(function () {
      // Download Scroller
      Scroller.initialize();
      // jQuery events
      $('body').on('click', function(e) {
        e.preventDefault();
        $('#device-btn').closest('.filter-row').find('.search-container-c').toggleClass('db', 
          $(e.target).is('#device-btn, .filter-icon, #search-dev, .search-li, .search-container-c .input-row')
        );
      }); 

      $('.detect-change').on('click', function() {
        $('.desc-change').removeClass('dr');
        $('.detect-change').removeClass('active');
        $( this ).addClass('active');
        $( this ).next().addClass('dr');
      });
    });
    App.start();
});

How to insert a view into the DOM? no callnew AsideView();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
timfcsm, 2015-12-24
@ogarich89

no way... the object must be initialized in any case, otherwise it simply does not exist, you only have a constructor. What is this "without calling new AsideView();" condition at all. why didn't he please you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question