Questions tagged [viewmodel]

The tag has no usage guidance.

2
votes
4answers
199 views

Can I and should I call Block methods from its' View Model?

I have a template and should write some logic. I have made a view model and I'm calling it from a template. Should I call block methods from the view model? And if so, how can I do it?
4
votes
2answers
545 views

When it is good to use viewModel ? What is difference between viewModel and Block?

I am bit confuse about using viewModel in Magento. I am not getting exact difference between viewModel and Block. In which case using viewModel is best case? Any help will be appreciated.
0
votes
2answers
431 views

Knockout.js What is the correct way to reference $parent on js file?

I am new on Knockout.js, especially on how to use it in the Magento way. I create a custom ViewModel with a js file called storepickup-select.js and an HTML template called storepickup-select.html. ...
1
vote
1answer
428 views

Magento 2 : What is use of observableArray in JS file with knockout JS?

I have checked observableArray word declared in js file at top position. I have been seen this function like this items: ko.observableArray([]). Is this function related to AJAX while response is ...
5
votes
2answers
2k views

Magento 2: How to Add a viewModel to a core block?

I am trying to overwrite a core template and add my custom logic using a viewModel as follow: <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...