frontend-developer-1
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Customize and Create JavaScript<br />
How do you use knockout.js bindings?<br />
Bindings are a way to link reactive data with HTML. They are connected with the<br />
data-bind attribute like:<br />
<br />
Assuming firstName is an observable in the Knockout model, the value of this.<br />
firstName will be automatically updated whenever the input’s value changes.<br />
There are many bindings available; here are some of the most common:<br />
• text: sets the innerText of an element.<br />
• visible: controls whether or not an element is visible.<br />
• if: similar to visible but removes or adds the child nodes based on the<br />
evaluation of the property.<br />
• click: calls the specified function when the element is clicked. It’s a oneway<br />
binding (HTML to Javascript) which differs slightly from other bindings<br />
that are bi-directional.<br />
• value / checked / options<br />
Magento also provides some custom bindings. All of them can be set as regular<br />
bindings in a data-bind="" attribute, but some also may be specified as virtual<br />
knockout elements, custom attributes or custom elements.<br />
All of the following are more or less equivalent if used within a knockout .html<br />
template:<br />
<br />
Copyright © 2018, SwiftOtter, Inc.<br />
91