Home  >  Article  >  Web Front-end  >  How Form Event Bindings work in KnockoutJs

How Form Event Bindings work in KnockoutJs

Barbara Streisand
Barbara StreisandOriginal
2024-11-26 10:58:09991browse

Como funcionam Bindings de Eventos de Formulário no KnockoutJs

This content is basically a translation of the original materials. The intention is to learn about KnockoutJs for Magento 2 and create content in Portuguese about KnockouJs.

Documentation

  • The data-bind syntax
  • Binding context
  • The "click" binding
  • The "event" binding
  • The "submit" binding
  • The "enable" and "disable" bindings
  • The "value" binding
  • The "textInput" binding
  • The "hasFocus" binding
  • The "checked" binding
  • The "options" binding
  • The "selectedOptions" binding
  • The "uniqueName" binding

Bindings

In KnockoutJs, bindings are the way to connect the logic of the ViewModel (the data and business logic) with the View (HTML). In short, it is through bindings that the user interface automatically reflects changes in your data, without the need to directly manipulate the DOM.

Bindings in KnockoutJs work through the data-bind attribute on HTML elements. This attribute is where you specify the binding you want to use and the associated values.

Form Events

Click

The binding click adds an event handler so that the chosen JavaScript function is invoked when the associated DOM element is clicked. This is most commonly used on elements tagged