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

Vue model binding does not work at removeWidget() #541

Closed
GeniusWiki opened this issue Oct 18, 2016 · 3 comments
Closed

Vue model binding does not work at removeWidget() #541

GeniusWiki opened this issue Oct 18, 2016 · 3 comments

Comments

@GeniusWiki
Copy link

I use Vue and gridstack. The widgets(i.e, Vue components) rendered by an array from vue.$data.widgets. When adding a widget, I call grid.addWidget() at Vue component mounted event. It is works.

However, I cannot figure out at good place to call grid.removeWidget(). Basically, if call vue.$data.widgets.splice(idx,1), vue will automatically reflects to UI - that gridstack widget is deleted but it leaves a blank area at deleted widget place. I think grid.removeWidget() needs to called somewhere. I tried "destroyed" or "beforeDestroy" event in that vue component. But gridstack reports error in removeWidget() - the node is undefined at subsequence removeNode() method.

I also try to call removeWidget() before vue updates $data.widgets.splice(), that will cause vue exception.

So, is it possible refresh the widgets layout rather than by removeWidget()/addWidget()?

@radiolips
Copy link
Member

If I'm understanding you correctly, you may want to try using a parameter when calling removeWidget.

https://github.com/troolee/gridstack.js/tree/master/doc#removewidgetel-detachnode

Try passing in false as the second parameter so that the node is not detached.

@phainv
Copy link

phainv commented Jan 4, 2017

Hi. I also use Vue.js. But i can't import girdstack from node_modules. Can you help me?

@radiolips
Copy link
Member

Closing for inactivity. Please reopen if you're still having a problem.

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

No branches or pull requests

3 participants