Home > Back-end >  Call function before the href Vuejs
Call function before the href Vuejs

Time:12-22

I'm trying to call a function on a click event before the href is invoked. I want to do this so that I can set a value to a given variable and then when I redirect to the new page I can access that variable via this.$parent.varName. This is what I'm trying to do but it won't call the function:

<a @click="openWorkflow(rec.id)" href="#/workflows">Edit</a> 

Not sure what I'm doing wrong here and/or if this is the right way to achieve what I want

CodePudding user response:

I'd take care of redirecting to the next page inside the openWorkflow function, then you can place it directly wherever you need it to be in the logic. If you're using vue-router, you can do this by just running router.push("#/workflows"). If you're not, you can still do the standard window.location.href = 'baseurl.com/#workflows'.

  • Related