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

Using he-tree-vue with nuxt throws an error on draggable on refresh #7

Closed
websiddu opened this issue Mar 21, 2020 · 4 comments
Closed

Comments

@websiddu
Copy link

websiddu commented Mar 21, 2020

First off thanks a lot for great work.

I'm using he-tree-vue in my nuxt project, this works perfectly when the server just started. But once the page is refreshed it shows the following error when dragging.

image

@phphe
Copy link
Owner

phphe commented Mar 21, 2020

Does the page be refreshed by hot reload? I created a nuxt project with he-tree-vue 1.1.2, it works well with hot reload. Could you create a reproduce or show your code?

@websiddu
Copy link
Author

It renders very well no problems with that.

For the first time when I drag an element it works fine.
If I reload the page, by hitting the refresh button and then try again it will throw that error above.

I think it got to do with the way the code is setting the id's so in nuxt this._uid are generated twice server side and the client side. But the code stores the server generated Vue Instances, but when all the scripts are loaded the data-tree-id are updated on the client side making startTree not findable as we lost the ids.

Personal opinion:
Using _uid is not recommended, it causes a ton of problems in the future.
Also finding the Vue instance by data attribute seems flakey.
May be consider using this.$el or this to find the Vue element or have a global window object?

@phphe
Copy link
Owner

phphe commented Mar 21, 2020

I got that, let me check.

@phphe
Copy link
Owner

phphe commented Mar 21, 2020

fixed in 1.1.4 the issue is nuxt does not update template with latest id. So I reassign treeId after mounted.

@phphe phphe closed this as completed Apr 9, 2020
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

2 participants