magento2: M2.3.1 template binding not working
Preconditions (*)
Magento 2.3.1
Steps to reproduce (*)
- Create a new empty module (example Alx_KnockoutExample)
- Generate a new route
(for example by using pestle
pestle.phar generate_route Alx_KnockoutExample frontend alx_knockout) - Associate a block to the route
(
pestle.phar generate_view Alx_KnockoutExample frontend alx_knockout_index_index Main content.phtml 1column) - Create the file Alx/KnockoutExample/view/frontend/web/template/hello.html
<p>Hello World</p> - Add the following code in content.phtml
<div data-bind="template:'Alx_KnockoutExample/hello'"></div> - clean cache and run
bin/magento setup:upgrade - Visit the url
<magentoBaseUrl>/alx_knockout
Expected result (*)
I should see the message Hello world as defined in the hello.html file
Actual result (*)
The content is empty and inside chrome console I get the following
Uncaught TypeError: Unable to process binding "template: function(){return 'Alx_KnockoutExample/hello' }"
Message: Cannot read property 'name' of undefined
at RemoteTemplateEngine.makeTemplateSource (engine.js:184)
at RemoteTemplateEngine.renderTemplate (engine.js:246)
at executeTemplate (knockout.js:5327)
at ko.dependentObservable.disposeWhen (knockout.js:5391)
at Function.evaluateImmediate_CallReadThenEndDependencyDetection (knockout.js:2183)
at Function.evaluateImmediate_CallReadWithDependencyDetection (knockout.js:2150)
at Function.evaluateImmediate (knockout.js:2111)
at Object.ko.computed.ko.dependentObservable (knockout.js:1964)
at Object.ko.renderTemplate (knockout.js:5383)
at update (knockout.js:5518)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (20 by maintainers)
@rani-webkul thanks. I confirm that now the bind is working in that way. So the docs should be updated
@aleromano89, nobody has access to the codebase. So the only way, for now, is to check it locally at the own machine.