Views - write-software/enginejs GitHub Wiki
Views
A view is the presentation part of the data. It is the view that displays the content on the screen. A view is responsibity for creating the HTML and when passed the data build the data binding output.
Example simple view
var homeView = new view("",{ url:"./views/home.html"});
The view class is passed the HTML and a JSON option object. If no HTML is passed then the view will look to use the url property of the options.
Options definition
- Url: the url to a html file.
- methods: These are user defined method that you design to help manipulate the view.
Standard Methods
- buildView(html): Re-Render the view with new HTML content.
- loadView(url): Promise, fetch the view HTML from the server.
- render(selector,data, id = "", append = false, replace = false): Normally called be the controller to render the view, The selector is where the view will be rendered.
- getElement(): This returns the base HTML element of view.
Events
- onupdatebind(bind,value): Triggered every time a data bind occurs.
Also see "Data Binding"