View and SubView handling
var LayoutController = require("bauplan.layout.controller");
or as part of the Bauplan bundle
var Bauplan = require("bauplan");
var LayoutController = Bauplan.LayoutController;
Set the view of the ViewWithLayoutModel named "foo" to "bar"
foo.view template
…
{layout view=view}
…
LayoutController.set("foo", "bar");
The result is as if a view helper calling "bar.view" had been inserted to "foo.view" which can be switched or updated without any effect on the other elements in foo.view.
See the example app for a basic demonstration of this.
If only one argument is passed, the ViewWithLayoutModel is set to the default ("site-content")
So the following call sets the view in "site-content" to "foo"
LayoutController.set("foo");
Setting the same view again is ignored
LayoutController.set("foo"); -> Does not run
Additional variables can be passed through to the view that is set. In this case, the "'article" view is loaded, with the options passed to initialize set to viewOptions
{layout view=view options=viewOptions}
…
LayoutController.set({
view: "article",
viewOptions: {
article: "foo",
redacted: true
}
});
setScroll will not only set the chosen view, but also sets the viewport back to top of the document
LayoutController.setScroll("login");
Existing subviews
If the subview to be loaded in context is already present and has a setLayout method, then that method will be executed instead of reinstantiating the subview. This enables lightweight udpates such as setting and removing classes rather than having to rerender the view
Returns
LayoutController
- Type
- instance
Requires
- jquery
- thorax
- Source:
Methods
genericView(template)
Loads the default view using the named template
Parameters
Name | Type | Description |
---|---|---|
template |
string |
- Source:
set(layoutopt, view)
Set the view of a ViewWithLayoutModel
Parameters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
layout |
string |
<optional> |
this.defaultlayoutview | |
view |
string | object | |||
view.view |
string |
<optional> |
View name |
|
view.viewOptions |
object |
<optional> |
View options |
- Source:
setScroll(view)
Set the view of the default ViewWithLayoutModel and scroll to the top of the document
Parameters
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
view |
string | object |
Properties
|
- Source:
(private) updateLayoutView(viewModel, viewValues, layoutId)
Generic layout setting handler
Parameters
Name | Type | Description |
---|---|---|
viewModel |
string | model | |
viewValues |
object | string | |
layoutId |
string |
- Source: