Reputation: 11
My Code:
$( "#tabs" ).tabs( "option", "active", 0 );
$( "#tabs" ).tabs( "disable", 1 );
$( "#tabs" ).tabs( "disable", 2 );
$("#tab3").text("");
$("#tab1").attr("href", "makerList");
$("#tab1").text(roleName+" Work List");
if(mode=='add'){
$( "#tabs" ).tabs( "enable", 1 );
$( "#tabs" ).tabs( "option", "active", 1 );
$("#tab2").attr("href", "makerAddUser");
$("#tab2").text("Add Client");
$("#tab2").click();
}
When I am clicking on an event in first page it is focusing on the second tab for some seconds but again getting redirected to first page.
I want to get the second tab get focussed .
Can any one please help?
Upvotes: 0
Views: 98
Reputation: 128791
The problem is that event.preventDefault()
isn't being fired on your tab click, so your element's href
property is being followed by your browser. I'm not sure how the jQuery Tabs plugin works, but I imagine this should be handled for you anyway, however a simple fix would be to add this in yourself:
$('[id^="tab"]').click(function(event) {
event.preventDefault();
});
This targets any element with an ID beginning with "tab" and calls preventDefault()
on the event for you.
The problem may simply be that you're not calling enable
on tab 2, however, and thus the plugin isn't handling that tab's click for you:
$( "#tabs" ).tabs( "enable", 2 );
Upvotes: 1