vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

How to rebuild a VM after DOM changed #39

Open zerosyn opened 10 years ago

zerosyn commented 10 years ago

I'm using vue and pjax in the same page. The html is replaced when navigated with pjax history back, but the VM doesn't work with the new DOM with same html, even after new it again.

Is there any way to rebuild the VM with all the old options and the new DOM? Or is there any workaround?

yyx990803 commented 10 years ago

What do you mean by "new it again"? Is the root element of the VM replaced by pjax?

zerosyn commented 10 years ago

Sorry, I've discard that plan and can't find the case now.

I wrote a test and found that "new it again" actually work. (http://jsfiddle.net/7Lveu/1/) Howerver, if there's a rebuild method, it would be easier to handle this case.