How to navigate to different page while coming back from activity in WL.NativePage.show()? - jquery-mobile

My scenario is this: I am using WL.NativePage.show(nativePageClassName, backFromNativePage, params) to navigate to an activity. Once returning back to the WebView, I need to navigate directly to other page(Div) in html, rather from the page I originally navigated from to the activity, which is developed using jQuery-Mobile.
See the below example code.
WL.NativePage.show("com.example.SignatureActivity", function(data) {
if(data.goToPage == "example2"){
$.mobile.changePage('#example2-page',{transition: 'none'});
}else{
$.mobile.changePage('#example1-page',{transition: 'none'});
}
});
Here I am using WL.NativePage.show() In example1-page, I have two buttons in activity, one is save and one is back, while saving I need to navigate to example2 and while back, its example1.
I am able to navigate to example2, but example1-page is executing and displaying first and then displaying example2-page.
Please give me suggestions on how to navigate directly to example2-page without displaying example1-page.

You can't navigate directly from the activity to a different place in the DOM which is in the WebView from which you navigated to the activity.
What you could do, is open displaying the activity, also hide the current content in the WebView. I assume it is a DIV essentially - so you could do something with display:none or any other standard method.
That way when the user returns back to the WebView from the activity and the code to change page is executed, you could then play again with the visibility of the DIV to display it when needed.
This way what you don't want to be seen will not be shown.

Related

How does iOS 13 Safari link preview work?

In iOS 13 Safari, when you long press on a link, you see a preview of the linked page, along with some menu items. If you tap the preview, you navigate to that page.
Now, I see how to intervene in the long-press-and-preview process. This used to be peek-and-pop, but in iOS 13 that's deprecated and we're supposed to use func webView(_:contextMenuConfigurationForElement:) and so forth. Fine, but how would I imitate what Safari does?
The problem is that as my preview provider I have to supply a view controller. So I'm going to need a different view controller with a web view showing the linked page. Okay, I can do that. But then when the user taps the preview to dismiss it, I want to respond by loading the same linked page into my real web view.
But that's the problem. That loading takes time. In Safari, by contrast, when you tap the preview, boom, there's the same page already loaded. How do they do that? How would I do the same thing? How can I load the page into a different view controller, cache it, and communicate that cached page back to my real web view?

Best way to realize multi page site in Vaadin

I'm working on pretty simple web side that cointains login screen (almost same as in demo presentation, white page with login and password) and main screen with sidebar and navigation bar. How should it be done? My plan is to build main screen using navigation bar, sidebar (just few buttons in layout basicly) and few layouts with content of the webside. On each button click change layout used to create content to another one, for example for Schudele button I'm gonna load layout that contains some tables, for About button plain text. Is it good idea?
So finnaly is should look like this:
init() function decides if user is logged or not and display Login page or Main page, Main Page is builded from modules like navbar, sidebar and content, content depends on sidebar buttons click. I'm right?
Handling it on your own is legit way to start or learn Vaadin. If you have a first grasp of this works out, the most common way to handle such a scenario is the use of the Navigator See the book of Vaadin.
With the Navigator you define Views and give them a name, register them with the Navigator. Then you can navigate your application with the Navigator, it takes care to give you nice ...#!view... URLs so the Users can have bookmarks and navigate your app also e.g. with the back button in the browser.
The Navigator hooks into an event system, where listeners (ViewChangeListener) can react to "before enter" and "leave". The "before enter" can be used to realize auth needs, since they are allowed to object entering a view.

How to navigate back to a Page and avoid reloading webview?

I have a Windows Phone Store app (XAML) with a Page (MainPage.xaml) that has a webview that loads content and URLs. At certain point i have to navigate to a different windows phone page (Page2.xaml), once the data there is submitted i navigate back to MainPage.xaml, but the webview control always reloads the content and user has to reenter the data again.
Is there any way to make a snapshot of the webview and load it when Navigating back to MainPage.xaml?
I have tried the NavigationHelper, but in the onNavigatingFrom event from MainPage when i try to save the Frame.Content, its the Page2 the one being passed in the NavigationEventArgs.
Any ideas?
One way to do it is to never leave the page. To do this, create two grids. One for the webview and one for the other view. When the page loads, show the first grid and hide the second grid. When you want to show the second view hide the first grid and show the second.
I have used this method in several apps on the phone and windows store and you can simulate popups this way as well.

JQM Popup doesn't popup when url has GET details in it

I have a page which displays a calendar/diary and lets you navigate back and forth using a form so the URL often looks like:
calendar.php?&month=6&year=2014
The popup works fine initially before there is any string after the .php. However, once the "&month=" etc is there the popup doesn't work. I note as soon as the popup loads it shows up #&ui-state=dialog in the url.
Is there a simple solution for this? (Other than changing the form to method=post, which I haven't yet tried).
Many thanks.
The simplest solution is to add:
data-history="false"
to your popup <div>. That will avoid URL modification when the popup is open.

How to avoid a blink when UIWebView loads HTML

I have a native iOS app that contains a tab bar. The view controller for each tab contains a UIWebView. When the user switches between tabs, I load the HTML in the corresponding web view. The HTML is fully cached on a device. Here is how I feed the HTML to UIWebView:
[self.webView loadHTMLString:htmlString baseURL:baseUrl];
baseUrl is a file URL pointing to a directory where all assets are located.
This works great in online and offline modes, however it takes time for the UIWebView to parse and render the HTML. As a result, the user sees a brief blink of a white background when switching between tabs. I'd like to remove it, because the user is able to tell that the UI is not native (native UI renders instantly).
I was thinking about taking a screenshot of the UIWebView once it's done rendering the HTML and caching it in memory. The next time the user navigates to that web view, the app displays the screenshot while the UIWebView is rendering the HTML in the background. Finally, the app swaps the screen shot with the actual UIWebView and takes a new screenshot. This is similar to how Google Chrome app works.
Does anyone know a better solution to this problem?
Depends on how you present that web view. I'm not really sure from your description how you do it, but since you're talking about a blink of white background, I'm going to assume there is a situation where you have a web view with a loaded html and then you switch it to another html. The solution for that case would be:
create a second web view,
load the new html to this new web view,
when that web view finishes loading html (you can find out if you use UIWebViewDelegate) you can then quickly switch it with your old web view (meaning you finally add the new web view to the view hierarchy at THIS point, not when you created it).
This way you'll have an instant switch between old and new html, however user will be left waiting and it is your decision what to do with it. You could use UIActivityIndicatorView for example.
When webViewDidFinishLoad: gets called you can do any number of things, make the webview visible, remove something that you had on top of the webview etc...

Resources