Close detail page and return to home - windows-phone-7

In my application, I have list of news... When user click on some item, I navigate him to page with detail:
NavigationService.Navigate(new Uri("/Detail.xaml?ID=" + listbox.SelectedIndex, UriKind.Relative));
On this detail page are also button prev and next, which navigate to next and previous items (also to Detail.xaml, just ID is increased or decreased by 1). However, if user go through some news and want to return to "homepage", he needs to push Back button many times. Is there any way, how can I just close this Detail.xaml? Open it modal or something? I don't want to use "go home" button, which just navigate user to main page because of loop when he tries to exit application...

When the next or previous buttons are clicked try calling NavigationService.RemoveBackEntry() in the OnNavigatedTo method. This will remove the page from the back stack, thus ensuring that when they hit the back button they return to the index page.

Related

Xamarin Navigation Issue on Back

I've three pages first showing List of my items on tap I'm redirecting it to a History Page with Object defined with static property with
await Shell.Current.GoToAsync($"/{nameof(DeviceHistoryPage)}");
then from this page i'm again redirecting user to show more details of each history item to next page with data as static property
await Shell.Current.GoToAsync($"/{nameof(DeviceHistoryDetailsPage)}");
I'm able to achieve this navigation and able to move back and forth from first page to second page but from second page once redirected to third page and i'm not able return back to previous page with back button present in navbar
Also I've tried registering routes as independent as well as a child in AppShell as follows
Routing.RegisterRoute($"{nameof(ListPage)}/{nameof(HistoryPage)}", typeof(HistoryPage));
Routing.RegisterRoute($"{nameof(HistoryPage)}/{nameof(HistoryDetailsPage)}", typeof(HistoryDetailsPage));

Page 'loaded' event behavior explanation - difference between navigateTo() and goBack()

I've got an app with a page xml definition that has a grid-layout with no children. During the page 'loaded' event, I create a bunch of child elements and add them to the grid-layout dynamically.
I navigate to another page and then call frameModule.topmost().goBack() to go back to the previous page.
On that main page, the 'loaded' event gets called again - BUT has the children I already added in the previous navigation - so looks like the page wasn't created again.
Interestingly, if from the same main page, I navigate to another page and then navigate back (i.e. w/o calling goBack()), then the 'loaded' event gets called but the page doesn't have the children I added - so looks like the page was freshly created.
My questions are:
When one calls goBack(), why is 'loaded' called on the previous page - even though it looks like the previously loaded page was being used.
Is this a bug?
Any way to determine in the 'loaded' function - whether this is truly a fresh page loaded or all elements have been created.
The major difference between goBack and Navigate is that goback just goes back up the navigation history stack, and acts the same as if the person hits the "back" button(android) or swipes to the right (iOS). Navigate goes forward and adds a new stack entry that you can goBack on.
Lets look at two examples:
So if I started on Page1 and Navigated to Page2, then Navigated to Page3 then the user hit my "< Back" button and in the code I then Navigated To Page1, my Navigation Stack would look like this:
Page1
Page2
Page3
Page1
If I then use the hardware back button (which triggers) goBack it will be Page3, then Page2, then Page1. The user would probably not expect being on Page1 and hitting the back button to put them on Page3 rather than exiting. So unless you are wanting a weird navigation; this would be normally considered unexpected/broken behavior.
Under proper navigation I might do this:
Page1
Page2 (Not stored in History: used "backstackVisible: false")
Page3
Then a Back from Page3 would actually put me in Page1, and a Back from Page 1 would exit the application. This would be the expected behavior.
Now as to the events.
The events for this page are NavigatingTo, Loaded, NavigatedTo -- they fire in that order.
The loaded event being called is not a bug; it is by design; when the page component is loaded -- it allows you to be able to set up the page element. All components have a "loaded" event. So this is a component level event not a page navigation type event. So for example; I've done this before:
<Switch android:loaded="fixAndroidSwitch"/> and then my fixAndroidSwitch routine fixed up something on the switch.
The NavigatingTo and NavigatedTo are actual Navigation events, and they do have a value passed as part of the argument:
function onNavigatingTo(context) {
if (context.isBackNavigation) { /* Do whatever */ }
}
For more information on page events; you can read my Blog post http://fluentreports.com/blog/?p=191 and it explains more

How to redirect a user to a previous page where the edit button was clicked

I have an index page where all the models are shown and when you click edit you go to edit page and after you change something you click update and you will be redirected to index, all fine there.
And now i have made a show view and in show view i made the same edit button to go to edit page and when you click update of course you will be redirected of to the index page and i don't want that. I want to redirect user to the page where the EDIT button was clicked.
How can i redirect users to the page where they actually clicked the edit button?
You can keep URL in session to go two pages back in Laravel:
$links = session->has('links') ? session('links') : []; // Get data from session
array_unshift($links, $_SERVER['REQUEST_URI']); // Add current URI to an array
session(compact('links')); // Save an array to session
Then you can go 2 pages back:
return redirect(session('links')[2]);
You can use:
return back();
It returns you to back as it is so obvious. You can research this and other helper functions here:
https://laravel.com/docs/5.3/helpers#method-back

Rewind back - not just $.mobile.changePage

History of my pages / activities is:
Home page (page0).
List of issues (page1).
Detail card of issue (page2).
Popup for confirmation to delete issue (not a page because of JQM popup isn't a page).
When I confirm deletion of issue and delete it, there is no reason to return back to page2 (it's content dropped). The only valid transition here - from popup to list of issues (back twice).
BUT.
When I jump from popup to page1 by $.mobile.changePage, history saves page2 as previous page (because jump was started at page2' popup).
So, when I press back on page1 I expect to return on page0 (rewind history), but returns to page2 which is invalid.
Guess valid behaviour here is:
Jump from popup to page1.
Erase page2 and popup from history at all - or something similar.
How to do it?

Refreshing entire page jqGrid paging

When a user double clicks on a row on my page, I navigate them to an edit screen which shows them some important information. When they submit that patient I gerimander jqGrid to take them page to the page that they were just viewing...
serializeGridData: function (postData) {
//debugger;
var pagInfo = $(this).se
debugger;
if ((rowFromTemp != "") && (pageFromTemp != "")) {
//debugger;
postData.page = pageFromTemp;
pageFromTemp = "";
rowFromTemp = "";
}
return postData;
},
I basically edited the postData in the serializeGridData function.
My question is, when I navigate to a different page lets say page 3 of 10 after I have edited information and returned to the correct page, when I click refresh of the whole page...
I want the user to return to the page that they just navigated to. Right now, it will return them back to the page that they initially returned from after editing information. So If I were to construct a timeline of events...
1) user see's paged information...
2) user selects row to edit
3) user navigates to edit page and does his thing then submits
4) user now is sent back to page where he came from...
5) user goes to a different page (either next or last)
6) user refreshes page
7) !! user is sent to page X from step 3 and 4 and Not 5 !!
I was hoping to to some kind of refresh of page event and set the correct page in there.
Is my methodology or thinking in correct here? Is there a way to ensure that the correct page is selected no matter what?
I just checked again. It would seem that if a user
1) navigates to page X
3) refreshes a page
he will be sent to page 1.
Maybe I am setting an unrealistic expectation. Maybe if they reload the whole page, they should expect to go back to page 1.
Well even so, how could I accomplish that task with the first workflow
In my opinion the real problem which you have is the usage of step 3: "user navigates to edit page and does his thing then submits". The step makes all the problems which you try to solve. Instead of going to another page one can create dynamically some controls which allows to edit the selected row. jqGrid provide inline editing or form editing for the purpose. You need just include editable: true property in the columns which you need to edit implement starting of inline/form editing on select of row or on double click. Alternatively you can use buttons from the navigator bar (see navGrid and inlineNav) or in addition column of the grid (see formatter: "actions").
If you still don't want to use any editing mode which provide jqGrid you can just place the whole content of the body of the main page inside of a div. You can hide the div using jQuery.hide instead of redirection to "edit page". You can load the content of "edit page" on the same main page (per jQuery.load for example). Then you can remove the loaded "edit page" and show the original main page. As the result the main page will be shown in exactly the same form as it was before starting of editing.

Resources