I have a marionette/backbone component I am trying to pass in parameters to to conditionally render elements in my .hbs template.
Something like so:
return Marionette.LayoutView.extend({
template: template,
tagName: CustomElements.register('search-settings'),
regions: {
propertyResultCount: '.property-result-count',
propertySearchSettings: '.property-search-settings'
},
events: {
'click > .editor-properties > .editor-btn-group > .editor-save': 'triggerSave',
'click > .editor-properties > .editor-btn-group > .editor-cancel': 'cancel'
},
initialize: function() {
this.showSave();
},
I'm rendering this view using:
this.settingsContent.show(new SearchSettings("search settings param"));
Is it possible to access this input parameter? I want to be able to pass in custom parameters
You need to pass object to constructor:
this.settingsContent.show(new SearchSettings({
searchString: "search settings param"
}));
And access it in Marionette view via:
this.options.searchString
And/or pass it to template via: templateHelpers (https://marionettejs.com/docs/v2.4.4/marionette.view.html#viewtemplatehelpers)