Skip to content

M2.3.1 template binding not working #24087

@aleromano89

Description

@aleromano89

Preconditions (*)

Magento 2.3.1

Steps to reproduce (*)

  1. Create a new empty module (example Alx_KnockoutExample)
  2. Generate a new route
    (for example by using pestle
    pestle.phar generate_route Alx_KnockoutExample frontend alx_knockout)
  3. Associate a block to the route
    (pestle.phar generate_view Alx_KnockoutExample frontend alx_knockout_index_index Main content.phtml 1column)
  4. Create the file Alx/KnockoutExample/view/frontend/web/template/hello.html
    <p>Hello World</p>
  5. Add the following code in content.phtml
    <div data-bind="template:'Alx_KnockoutExample/hello'"></div>
  6. clean cache and run bin/magento setup:upgrade
  7. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: UiIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: doneReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject itstale issue

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions