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

Create additional events for wizView #66

Open
gen-failure opened this issue Aug 27, 2014 · 1 comment
Open

Create additional events for wizView #66

gen-failure opened this issue Aug 27, 2014 · 1 comment

Comments

@gen-failure
Copy link

Greetings,

I need to add additional events to my wizView, specifically:

Whenever user starts to load a new page (like clicking on a link in webview) I want to receive event in my cordova web view, something like wizViewStartLoading.

Similarly, when the the page loading is finished, I need similar event like wizViewLoadingDone.

Now, I checked the plugin architecture and it seems to me that the best solution should be to send message over wizMessenger to mainView using loadUrl("javascript:...") from to overrided onPageFinished and newly override onPageStarted.

The similar approach should work on iOS as well.

Is this the right way how to reach my needs or do you have better idea?

@aogilvie
Copy link
Contributor

@MichaelBln Sorry for the late reply.

wizMessenger could be used, but I see that API a replacement for postMessage.

But I think your idea is the best way. We could add native code to execute JavaScript event using Cordova's document event code as follows:

// On WizWebView.m
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSMutableURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
...

NSString *js = 
    [NSString stringWithFormat:
        @"cordova.fireDocumentEvent('wizViewStartLoading', { viewName : \'%@\' })", theCustomViewName];
    [cordovaView stringByEvaluatingJavaScriptFromString:js];
...
}

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