Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a node based on template parameter, then apply bindings to it. #2574

Open
Gle2nn opened this issue Aug 9, 2021 · 0 comments
Open

Comments

@Gle2nn
Copy link

Gle2nn commented Aug 9, 2021

A question rather than an issue per se.
I am trying to write a template that will create either a 'div' or 'span' element and then populate it with markup.
I have worked around the issue by testing the element name and creating the node and contents but am looking for a better way.

Pseudo-code (current):
if containerNode == "div" <div data-bind="attr: ...">...</div> if containerNode == "span" <span data-bind="attr: ...">...</span>

What I'd like to do is:
<ko createElementNode: "div"> ...Not sure how to specify the bindings that would apply to the node created in createElementNode.... </ko>

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant