eng_mazzy
eng_mazzy

Reputation: 1049

force the url showing a page in jquery mobile

Is there a way to force a URL in a jQuery Mobile page in the way it can show me what I want. For instance, I created a multiple-page-template in jQuery Mobile and when I click to a link it shows me the second page and in the URL there is the ID of my second page in the form: #id-page.

Now, since I have started to use this function:

<script type="text/javascript">
  $(document).delegate('#info-button', 'click', function() {
    $.mobile.changePage($('#info'), {
        changeHash : false,
        role       : 'dialog'
    });
  });
</script>

I don't see the #id-page in the URL. Now I would put in the URL some name created from me. What can I do?

Is there a way to use the API jQuery Mobile dataUrl?

Upvotes: 1

Views: 291

Answers (1)

Jasper
Jasper

Reputation: 76003

You're talking about the URL's hash changing when viewing different pages. Well right in your code you're telling the jQuery Mobile framework to not update the hash with this line:

changeHash : false,

Try this:

<script type="text/javascript">
  $(document).delegate('#info-button', 'click', function() {
    $.mobile.changePage($('#info'));
  });
</script>

Notice that no options are being passed to the $.mobile.changePage() function, so it's using it's default settings.

Here is the documentation for $.mobile.changePage(), notice the different options you can set and what they mean: http://jquerymobile.com/demos/1.0.1/docs/api/methods.html

Upvotes: 1

Related Questions