Skip to content

Commit

Permalink
fix: remove include knockout via layout xml step
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjitse-E authored Sep 8, 2023
1 parent c1757d5 commit 918d612
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions knockoutjs-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ beneficial as well.

To integrate KnockoutJS into your Magento 2 project, follow these steps:

1. Include KnockoutJS library: Add the KnockoutJS library to your project by including the following line in your
template file or layout XML:
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
```

2. Create a View Model: A view model is a JavaScript object that represents the data and behavior of your UI components.
1. Create a View Model: A view model is a JavaScript object that represents the data and behavior of your UI components.
In Magento 2, you can define a view model in a separate JS file or inline within a script tag. Here's an example of
defining a view model inline:
```html
Expand All @@ -39,13 +33,13 @@ To integrate KnockoutJS into your Magento 2 project, follow these steps:
</script>
```

3. Bind Data to the UI: To bind data from the view model to the UI, use KnockoutJS data binding syntax. You can use
2. Bind Data to the UI: To bind data from the view model to the UI, use KnockoutJS data binding syntax. You can use
the `data-bind` attribute on HTML elements to specify the binding. For example:
```html
<div data-bind="text: message"></div>
```

4. Handle User Interactions: KnockoutJS provides a set of event bindings to handle user interactions. You can use
3. Handle User Interactions: KnockoutJS provides a set of event bindings to handle user interactions. You can use
the `click`, `submit`, `event`, and other bindings to attach event handlers to HTML elements. Here's an example of
handling a click event:
```html
Expand Down

0 comments on commit 918d612

Please sign in to comment.