non-emptying.region
NonEmptyingRegion : d2/sdk/controls/regions/non-emptying.region
A Marionette.Region
that does not empty it's DOM element on rendering new instance of Marionette.View
.
Extends: Marionette.Region
Example
define([
'nuc/lib/underscore',
'nuc/lib/marionette',
'd2/sdk/controls/regions/non-emptying.region'
], function(_, Marionette, NonEmptyingRegion){
'use strict';
var MyView = Marionette.LayoutView.extend({
template: false,
constructor: function MyView(options) {
options = options || {};
MyView.__super__.constructor.call(this, options);
},
onRender: function() {
if(_.isString(this.options.greet) && !_.isEmpty(this.options.greet)) {
this.$el.text(this.options.greet);
}
}
});
var view1 = new MyView({greet: 'Hello'});
var view2 = new MyView({greet: 'World'});
var region = new NonEmptyingRegion({el: '.host-element'}); //can also set prependChild: true if element for view added later should show before previously added element in DOM.
region.show(view1); //Adds element with 'Hello' in the DOM
region.show(view2, {preventDestroy: true}); //Adds element with 'World' in the DOM, however element with 'Hello' is not removed and still exists in the DOM.
//With normal Marionette.Region, after adding view2, the HTML element specific to view1 would have been removed.
});
- NonEmptyingRegion :
d2/sdk/controls/regions/non-emptying.region
nonEmptyingRegion.show(view, [options])
Shows a Marionette.View
in the region.
Kind: instance method of NonEmptyingRegion
Param | Type | Description |
---|---|---|
view | Maionette.View | The view to be shown |
[options] | object | Display control options |
[options.preventDestroy] | Boolean | Indicates whether previous view should be destroyed before showing current view or not. This flag is an important indication that tells the |
NonEmptyingRegion~NonEmptyingRegion
Kind: inner class of NonEmptyingRegion
new NonEmptyingRegion([options])
Param | Type | Description |
---|---|---|
[options] | object | Constructor options. Usual constructor options as per |
[options.prependChild] | Boolean | Flag to indicate whether current view's element is to be placed before or after previous view's element in DOM when |
[options.index] | number | Positive integer to indicate any specific ordered spot for current view's element in the DOM when a previous view exists and current view is being shown with |