Marko Widgets Taglib ==================== # Custom attributes ## ref Used to assign a _scoped_ ID to a nested widget or a nested DOM element. The ID will be a concatenation of the parent widget ID with the provided value of the `ref`. ### Examples #### Using `ref` with an HTML element ```xml
``` This will produce output code similar to the following: ```html
``` The containing widget can reference the nested DOM element using the following code: ```javascript var myButton = this.getEl('myButton'); ``` #### Using `ref` with a nested widget ```xml
``` This will produce output code similar to the following: ```html
``` The containing widget can reference the nested widget using the following code: ```javascript var myButton = this.getWidget('myButton'); ``` ## w-on* The `w-on*` can be used to declaratively bind event listeners to a DOM element or widget. NOTE: For DOM events that bubble, efficient DOM event delegation will automatically be used to avoid attaching direct event listeners for performance reasons. ### Examples #### Using `w-on*` with a nested HTML element ```xml
``` When the button HTML element is clicked, the `handleMyButtonClick` method of the widget will be invoked: ```javascript module.exports = require('marko-widgets').defineComponent({ // ... handleMyButtonClick: function(event, el) { // event will be the native DOM event // el will be the native DOM element } }) ``` The containing widget can reference the nested DOM element using the following code: ```javascript var myButton = this.getEl('myButton'); ``` #### Using `w-on*` with a nested widget ```xml
``` For the example above it is assumed that the nested widget will emit the custom event using code similar to the following: ```javascript this.emit('handleSomeCustomEvent', { foo: bar }); ``` ## no-update Preserves the DOM subtree associated with the DOM element or widget such that it won't be modified or rerendered when rerendering the UI component. Example: ```xml
...
``` ```xml
``` ## no-update-if Similar to [no-update](#no-update) except that the DOM subtree is conditionally preserved: ```xml
...
``` ## no-update-body Similar to [no-update](#no-update) except that only the child DOM nodes are preserved: ```xml
...
``` ## no-update-body-if Similar to [no-update-if](#no-update) except that only the child DOM nodes are preserved: ```xml
...
``` ## :no-update This custom attribute is used to prevent select DOM elements from being modified during a rerender: ```xml
...
``` #### w-for The `w-for` attribute is used to render a `for` attribute that references a scoped widget element: ```xml
``` This will produce code similar to the following: ```html
``` # Custom tags ## `` Generates the necessary code to initialize widgets associated with UI components rendered on the _server_. Supported attributes: - __`immediate`__ - If true then a ` ``` When immediate widget initialization is enabled, widgets will be initialized before the DOM ready event. In addition, inline widget initialization code will be appended to each async fragment. ## `` Used to conditionally bind a widget: ```xml
...
``` The `` can also be used to disabling binding of a widget: ```xml
```