Anthonty23
Anthonty23

Reputation: 21

Using jquery mobile framework with MVC3

I have the problem with url link in my MVC application when I use jquery mobile libraries

here is my header reference

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<script src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>

Example

http://www.mysitename.com

if I go http://www.mysitename.com/home/audit it works fine but if I click any link button within my application it starts appending # and then url look like http://www.mysitename.com/home/audit#home/audit

The only time it happens when I use jquery mobile framework

Upvotes: 1

Views: 1376

Answers (2)

Yekmer Simsek
Yekmer Simsek

Reputation: 4102

Jquery mobile wraps all links so that it will send and ajax request by default. If you don't want this behaviour add rel="external" attribute to your a tag like below.

<a href="multipage.html" rel="external">Multi-page link</a>

You can read the documentation for more detailed information

http://jquerymobile.com/demos/1.0rc1/docs/pages/page-navmodel.html

Upvotes: 1

Anand Patel
Anand Patel

Reputation: 39

If you don't want # in ur url and want clean URL then you can use target attribute of anchor tag. You can use anchor tag using Below 2 technieqs in MVC

1) Direct in Anchor Tag

LinkText

if you use jQueryMobile then you can also give data-role="button" to give anchor tag look like button

2) Using HTML Helper

@Html.ActionLink("Log Off", "LogOff", "Account", null, new { target = "_self" })

In above both case we set target="_self" attribute of anchor tag nothing else. Let me know will it work for you or not.

Upvotes: 0

Related Questions