how to convert mithril.js code to vanjs #355
Replies: 9 comments 11 replies
-
``I managed to convert the node code (see below). however, not sure how to do redraw with vanjs....is van.add the only way to refresh to display new dom element? e.g. when click the + button, how to display new node? then how to remove existing node if clicking on X button? `App.views.Node = function ({mykey}) {
} |
Beta Was this translation helpful? Give feedback.
-
thanks...could you please advise how to create a tree with vanjs? it seems it is not easy to dynamically add/remove child component if just using html element directly. appreciate any code example |
Beta Was this translation helpful? Give feedback.
-
Thanks...I did look at the example and also used vanjs app builder which produced following code, but the line I noted below returns sth like [object HTMLLIElement]...remove function doesn't work either. can you please advise how to correct it?
|
Beta Was this translation helpful? Give feedback.
-
I changed the line: ul(() => children.val.map(child => child())) into: () => ul(children.val.map(child => child())) I think now it works. Basically, for state-derived child node, the derivation function needs to return a single DOM node. Returning an array of nodes doesn't work for VanJS. |
Beta Was this translation helpful? Give feedback.
-
it works..thanks very much...maybe this could be another good example to add to the list of examples for others reference |
Beta Was this translation helpful? Give feedback.
-
I put this together as a pwa app that people can play with and refer as example. please feel free to include in community example |
Beta Was this translation helpful? Give feedback.
-
cool...thanks...hope it provides some good examples and references. keep up with the good work of vanjs...I love it and plan to continue using it for my app development |
Beta Was this translation helpful? Give feedback.
-
regarding your comment: I think now it works. Basically, for state-derived child node, the derivation function needs to return a single DOM node. Returning an array of nodes doesn't work for VanJS. how to handle it for select/options. for code example below, how can I wrap up options with one single DOM? thanks.
|
Beta Was this translation helpful? Give feedback.
-
thanks for your quick response and help. btw do you have any recommendation how to work with shadow DOM? especially how to extract and restore innerHTML of it? |
Beta Was this translation helpful? Give feedback.
-
hi, wondering if there is an example, tutorial or tool to convert mithril.js code to vanjs, e.g. a tree view based on mithril.js below...how to convert it to vanjs?
Beta Was this translation helpful? Give feedback.
All reactions