0

I have a jQuery Mobile app that's just like the dynamic page sample from the jQuery Mobile documentation http://jquerymobile.com/test/docs/pages/dynamic-samples/sample-reuse-page.html.

Everything works fine, but just as in the example I can't get the page titles to change accordingly to the requested page. On the basis of the example: When you click the category Colors in the Categories section, the new page has the title Colors, but when you go back and then select Vehicles, the page title is still Colors. How can I fix this?

I tried $page.attr('data-title', category.name) in the showCategory function but it won't work. Any ideas?

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
ericS
  • 11
  • 4

2 Answers2

1

You can also use something like this -

$("title").html(category.name);
Carl0s1z
  • 4,683
  • 7
  • 32
  • 47
  • jquery mobile has a built in page title system ... original post mentions the 'data-title' attribute. So although your answer is correct from an html point of view, it is not correct from a jqm pov. Doing this on a jqm site would basically be a conflict. – dsdsdsdsd May 11 '13 at 22:28
  • You can try something like this - $("#div-id").data("title", "New Page title"); That's worked for me. Thanks. – Mahbub Alam Khan Aug 07 '13 at 17:26
0

I don't see the behaviour you're describing in the example. However, to change the title wouldn't this do the job?

document.title = category.name;
scottlimmer
  • 2,230
  • 1
  • 22
  • 29