crysalead-js / dom-layer

Virtual DOM implementation.
MIT License
30 stars 1 forks source link

server side rendring #50

Closed ghost closed 9 years ago

ghost commented 9 years ago

First off I tried this example: https://github.com/crysalead-js/dom-layer#server-side-rendering

Nothing happen, and nothing got attached somewhere. And nothing are replaced in the browser?

If you do .toHTML() and try to attach the generated HTML, you got a bunch of errors.

So what is the purpose? The given HTML should replace the other one and have a click event? Doesn't happen in my end.

ghost commented 9 years ago

This is probably not an issue for the rendered HTML is visible in the console.log. Only thing I didn't get here is why you attach a click event on that button when it's pure HTML?

And I didn't figure out what you mean with "the part rendered by the server side"

For if I'm using the attach() method, nothing shows up. Seems pretty dead to me.

jails commented 9 years ago

It's not that I'm not trusting you but I would prefer to read some code. I'm not that clairvoyant ;-) ! Bellow a proof of concept: https://jsfiddle.net/buf3wa3d/

ghost commented 9 years ago

Yup. That works, and I know now what the issue was! The readme file is not correct, and confused me. At least if the purpose was to illustrate server side rendring.

In the readme :

var mountId = tree.attach("#mount-point", button); // using attach() instead of mount().

Then in the example, you are using a third argument for the attach method not mentioned in the readme. Second is that you in the callback function are calling / trigger the .toHTML data. Not menttioned in the readme either to get this to work.

jails commented 9 years ago

Ok, I updated the README in https://github.com/crysalead-js/dom-layer/commit/56a28453c3264e78a94f769e344ad8cde70e9850