sandraqu
sandraqu

Reputation: 1528

jQuery not working with hash in URL

Using jQuery Mobile with ThemeRoller theme, the accordion menu delivers a URL with hash when "Cake Sizes" is clicked. The ThemeRoller theme does not load with has in URL.

<div><h3><a href="#">Cakes</a></h3>
<div id="accordion-child">
<div><h3><a href="/cakes/cake-sizes" data-transition="slideup">Cake Sizes</a></h3></div>
<div><h3><a href="/cakes/flavors">Flavors</a></h3></div>
<div><h3><a href="/cakes/gallery">Gallery</a></h3></div>
</div>
</div>

When click "Cake Sizes" URL is http://example.com/#/cakes/cake-sizes

How do I prevent # from ending up in URL or how do I remove it? Does anyone know why Themeroller theme will not load with hash in URL?

Upvotes: 0

Views: 438

Answers (2)

Ra.
Ra.

Reputation: 955

By default jquery mobile using ajax calls to load pages. So the "#" included automatically in the url. To avoid that,use

data-ajax="false"

to disable ajax call on the hyperlinks. And try like this

<div><h3><a href="#" data-ajax="false">Cakes</a></h3>

Hope it works...

Upvotes: 0

Anirudh Ramanathan
Anirudh Ramanathan

Reputation: 46788

Why do you have the # in the href for cakes anyway. Leave it blank and it will behave in the same manner.

Upvotes: 0

Related Questions