0

I have a page with a button that directs the user to the previous page:

<div class="ui-block-b"><a data-role="button" data-rel="back">Cancel</a></div>

This works great, however I'd like to also append this string to the end of the url after the page is navigated back (this string just navigates to a particular tab on that page):

"?tab=tab-messages"

Is there any type of jquery function that I could use to append this?

DannyD
  • 2,732
  • 16
  • 51
  • 73
  • Is this link always going back to the same page (exact same url)? Or is it going back to the relative previous page? – adamdehaven Apr 23 '13 at 15:52
  • The page is going to different pages depending on how the user navigated to the page. If it was the same page, I would have just navigated directly their. However, the data-rel="back" works great right now. I just want it be go to a default tab by appending my small string to the end after it's gone back. -Thanks – DannyD Apr 23 '13 at 15:58
  • thanks for your answer Adam. But it didn't quite work. The "parent.history.back()" function runs but does not include the additional parameter in the url. – DannyD Apr 23 '13 at 19:24
  • Yes... check out the two links I also included. Although they don't provide an answer to your exact question, they do reference most of the info regarding URL parameters in accordance with jQuery Mobile, and the limitations associated with it. – adamdehaven Apr 23 '13 at 19:30

1 Answers1

0

You could try something like this (although it will probably take some tinkering to get it working exactly as you'd like). This is untested.

$(document).bind('pageshow', function() {
    $(body).on('click', '#id-of-back-button', function(){
      parent.history.back() + '?tab=tab-messages';
      return false;
  });
});

If this doesn't lead you anywhere, please see the accepted answer on How to pass parameters while changing the page in JQuery Mobile?

Also this may help: Get param value from a URL in jquery mobile

Community
  • 1
  • 1
adamdehaven
  • 5,890
  • 10
  • 61
  • 84