-
Notifications
You must be signed in to change notification settings - Fork 37
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
Duplicate widget ID when manually initializing server side rendered widgets #40
Comments
This "problem" has been reported before and @patrick-steele-idem already proposed a fix. Please see: #16 |
AAh. Thank you for pointing it out. Will looking into it. Karthik |
What @tindli pointed out should solve your problem. The Marko Widgets server code is stateless so it doesn't know how to generate unique widget IDs for a given client if additional widgets are being rendered on the server after the initial page rendering. Therefore, it is up to your app code to tell Marko Widgets what to use as the starting widget ID to keep widget IDs unique. This needs to be moved into the docs since it has come up a few times for teams that want to do all of the rendering on the server. I'll keep this issue as a reminder to update the docs. |
👍 for moving it into the docs. thanks |
Awesome. Thanks guys :) |
Hello,
Was trying out manually initializing server side rendered widgets (https://github.com/raptorjs/marko-widgets#manually-initializing-server-side-rendered-widgets) and have run into an issue.
Say there exists a parent widget.
<div w-bind="./parent_widget"></div>
The above widget would get an ID "w0".
Now, if parent_widget makes an ajax call that renders a child_widget on the server side and we manually try to initialize the widget on the browser with:
require('marko-widgets').initWidgets(widgetIds), the child widget fails to get initialized because the child_widget also comes back with the same ID 'w0'.
I put a break point on the initWidgets function and noticed that the child widget also comes back with widget id "w0" (same as the parent widget). Ideally, the client_widget should have come back with "w1".
Was wondering if i am missing something ?
Regards,
Karthik
The text was updated successfully, but these errors were encountered: