开发者

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜