Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Execute vue method on server-side via webviewext #82

Open
giulianimartini opened this issue Jun 17, 2020 · 4 comments
Open

Execute vue method on server-side via webviewext #82

giulianimartini opened this issue Jun 17, 2020 · 4 comments

Comments

@giulianimartini
Copy link

Hi,

how can I execute a Vue method on my server-side code called by my Nativescript app?

In my server-side I have a vue method called refreshPage() and I want to execute it by calling it from the NS app. I have read about emitToWebView in the documentation, but I can't find any example on this.

I am using version 6.5.2 of webviewext: "@nota/nativescript-webview-ext": "^6.5.2";

Can you help me?

Thanks in advance.

@giulianimartini
Copy link
Author

giulianimartini commented Jun 18, 2020

Hi,

I managed it by doing a click on my refreshButton (then I just update the reactive data on server-side (vue)):

let webView = this.$refs.webViewReservas.nativeView;

const refreshButton = `document.getElementById('refreshButton').click();`;
webView.executeJavaScript(refreshButton);

It would be nice if someone manage to solve it in another way (like calling the vue method directly).

@m-abs
Copy link
Contributor

m-abs commented Jun 19, 2020

It is very hard to help without a more complete code example, showing the problem.

I don't know anything about Vue, making it even harder to help.

@giulianimartini
Copy link
Author

giulianimartini commented Jun 19, 2020

Hi @m-abs,

Thanks for your time.

My scenario is like this:

  • Server-side (Laravel + vue):

I have a server-side code that refreshes the page.

methods: {
    refreshPage() {
        window.location.reload();
        //instead of reload, I call other vue methods here, so window.location.reload() will be replaced by other vue methods.
    }
}
  • Client-side (Nativescript):
methods: {
    executeRefreshPageOnServerSide() {
        let webView = this.$refs.webViewReservas.nativeView;

        //I want to access the refreshPage() vue method on server-side by the webview reference.
    }
}

Note: if the refreshPage() method is in a <script> tag, it works, but that isn't my case. It's in a vue instance inside the methods (to listen to DOM events).

@m-abs
Copy link
Contributor

m-abs commented Jul 30, 2020

It would be much better, if you create a small test project demonstrating the problem. Either as a github repo or attached as a zip-file.

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

No branches or pull requests

2 participants