Reputation: 591
I have a tabs on a page:
<div id="tabs">
<ul>
<li><a href="#tabs-1">tab1</a></li>
<li><a href="#tabs-2">tab2</a></li>
<li><a href="#tabs-3">tab3</a></li>
</ul>
<div id="tabs-1">
</div>
<div id="tabs-2">
</div>
<div id="tabs-3">
</div>
</div>
Action on the controller of the page looks like:
public ActionResult PageWithTabs(int id)
{
return View();
}
Link to the page is:
http://localhost:65334/Home/PageWithTabs/1
and when I click a tab it goes through link
http://localhost:65334/Home/PageWithTabs/1#tabs-2
and invokes my action with null id(obviously - 1#tabs-2 not int) and I have an exception.
So, how can I prevent invoking of action on tab clicking?
I found out the reason of waking of the action - there is uploadify plug-in on a tab, but I still don't know how to fix it.
Upvotes: 1
Views: 503
Reputation: 7590
Try this:
$('a').on('click', function (ev) {
ev.preventDefault();
// your click logic...
});
Upvotes: 1