jQuery Mobile NavBar with back button of previous page - jquery-mobile

On an iPhone when you have a NavBar at the top, there is a back button.
Rather than say "Back" it has the title of the previous page in it.
So you might be on say the "Checkout" page. The title of the NavBar would be "Checkout" and the button might say "Books".
Clicking on the button that says "Books" takes you back to the previous page.
How can this be accomplished in jQuery mobile without the need to code in the name of the back button as you may have gotten to that page from a different route?
edit
I know I can do this on the page;
<div data-role="page" id="pageViewChallenges" data-add-back-btn="true" data-back-btn-text="previous">
But that makes the buttons text "previous" instead of the name of the page.

U can use
Books
(If u r using external page)
and
Books
(When using Internal page)
This is simple settings to customise back button and if u want previous page title as back button then simply get the title of back button through jquery method and set in the back button title.IF u can get the previous page title then set it on pageshow event by getting the id of back button using jquery like this:
$('#MaterialAndQuantityDetails')
.live(
'pagebeforeshow',
function() {
// page header Management
$('#bkbtnid').html("");
$('#bkbtnid').html(BackButtontext);
});
And if u r thinking how to get the title of previous page then on previous "pagehide" write the code
var BackButtontext = document.getElementById('previous_page_header_id').value;
Here BackButtontext is global variable that is to be used to set the back button text.

Related

How to realize the automatic jump to the specified page

i want to do a function,that is in page-based,i add a button,when i click the button,pop-up a Select box.In the selected box input the page number,but how can i realize that when i input the page number,the page jump to the specified page
edit:
I want to do a calendar,the label title bar in the top i have used button,now,it is that when i press the button,it will pop up a marquee,in there have month.now ,i want to press a month in the press box,then turn to the corresponding page.

JQueryMobile Back to Previous Page

I have a JQM page with some events on html elements that will change DOM of the page. e.g. clicking a button will add a paragraph on the page. The page also have a link that will load another page via ajax. The new page have back button, but the problem is that when the back button is triggered, it will go to the previous page with the original content. What I want is to retain the modified DOM of the page. How can I do this with JQM?
Thanks.

jQuery Mobile - Page is not reloading

I am new to jQuery Mobile. I am trying to move from page #one1 to #page2. #page2 contains an address book form. If I fill something in the form and click on the back button to move to #page1 and then I again move to #page2, the form will show all the previously filled data.
I want that when I go back to #page2 all the fields be blank.
I have also tried it with putting an alert. The alert will popup the first time but it is not showing when I revisit this page again.
$('#page2').live('pageinit',function(event){
alert("Edit");
});
Thanks
Vivek
In the button that shows up #page2, don't move right away to #page2, first call a function that clears the fields. And then you can move to #page2...

jQuery mobile : correct way to use button?

I'm starting with jQuery mobile and have some problems with my buttons.
The web application is a shopping list. It displays a list of items to shop and in the footer buttons on actions I can perform on the items.
The actions are:
increment number of items to buy
decrements number of items to buy
move item up in list
move item down in list
add new item
delete item
modify item text description
The actions are implemented in javascript and works fine. The problems I have is with controlling the buttons and the associated actions.
By experience, I have see that for the increment and decrement it is more convenient to have a button with an active state, for the other operations it is preferable to have a selected item and apply the action on the selected item when the button is pressed. When adding an item, the item would be inserted before the selected item, and if pressed when no item is selected, the new item is appended to the list.
I would also like to have 2 modes. In one mode, only the increment and decrement buttons are shown and the user can update the number of items in its list. In the other mode the user is modifying its list. It is in the second mode that the selected item is required.
I managed to associate a default action my item lists by using the .on() method as a delegate.
$('#itemList').on( "click", ".item", function(evt)
{ ctrl.doAction($(evt.currentTarget)); });
Here is the html code I use to test the first mode.
<!-- footer -->
<div data-role="footer" data-position="fixed" class="ui-bar" id="btnBar" >
Plus
Minus
</div>
<!-- /footer -->
What should I put as href value ? I don't want the page to be reloaded. In some examples I see "#".
This is how I associate the action to the button:
$('#btnPlus').on( "tap", function(evt)
{ ctrl.doAction = ctrl.increment; });
Another problem I have is that there is no feedback on the button click action. When I click a button I would expect to have it highlighted for a short time. This doesn't happen.
The browsers have also different behaviors. In firefox, the clicked button gets a blue halo apparently showing that it has the focus. But the button isn't displayed as active.
If I put "#!" as href (don't know what it means) on Android, the clicked button is shown active.
Should I use click or tap as event type ? How could I write click or tap ?
How could I implement a two state button displayed as active and inactive ?
How is an action button used : always displayed inactive and feedback when pressed ?
I solved the problem my self.
to switch between sets of buttons in the footer, I create multiple footers in my HTML document with style="display:none" in the hidden footers. The one without this will be shown. I assigned a specific id to each footer so that I can write $("#footer1").hide(); $("#footer2").show();
I have buttons to switch between footers. The footer switching event handler must be called with the "mouseup" event. This is required for it to work on the iPad and Android phones.
To change appearance, don't use .button() as suggested here. Use:
$("#myButton")
.removeClass( "ui-btn-up-a ui-btn-down-a ui-btn-hover-a" )
.addClass("ui-btn-up-b")
.attr( "data-theme", "b" );
Note: There was a bug in my code which caused desperate hair pulling

how to refresh partial view without refreshing the complete page in mvc

I m using a Ajax Tab panel in my application.
There are 4 tabs on Left hand side and a partial view on right hand side.
In each of these tab I m displaying some data and there is a select link button on each tab.
when I click on any of the select link button I m filling the partial view with some information.
When this happens my view is completly loaded again.
A B C D
eg these are the tabs.
let us suppose that I m on tab B and now when I click on the select link button My view is completly loaded with information.
but the tab loose the focus at this point. I comes back to the default value.
so I want help on this
1) either I have to refresh only the partial view without loading the complete page
2) or I need to maintain active tab index value on click on select link button
Please help me with this problem
and provide me examples
jQuery Tabs - Load contents only when clicked
Here is the example which loading content of the tabs dynamically by Ajax. It is for PHP what you need to change is put controller/action instead of URL of the PHP page.
$.get("controller/action", {tab_clicked, "my_tab"}, tab_fetch_cb, "text/json/xml");
or else instead of Ajax.ActionLink
use <a onclick="LoadTab(#item.ID)">Item #item.ID</a>
and jquery function to change the tab and load data dyanamicaly
function LoadTab(id){
//Change tab here Ex: $('#tabs').tabs('select', index);
$.get('ajax/test.html', {Id, id},function(data) {
$('#Partial_Controller_Name').html(data);
});
}
Write an ajax call on click event of tab and load the partial view in the container of the tab
This can be done using RjsResult class
if using mvc1 u can use RjsResult.cs
by this..you can update as many div you want in a page...
use this for implementation
public ActionResult Some_Method(){
RjsResult r = new RjsResult();
ViewData["SomeData"] = Some_Function();
r.update("DIV_id","PartialPagePath",ViewData,ControllerContext);
return r;
}
so when you click on somethink..this function will be implemnted and will refresh you div with tht partial
View part
<div id="DIV_id"></div>
you can update as many dv as you want with a single click :)

Resources