I am new to jQuery. I am trying to convert this jQuery code so that it persists after I call a .Net Ajax partial postback in my page. The code below runs when the page initially loads, but not after I do a postback in the updatePanel.
Do I need to use the .live function somewhere else in my code to get this to work?
Code:
<script type="text/javascript">
$.noConflict();
$(document).ready(function() {
//Default Action
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").live('click', (function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
return false;
}));
});
</script>
A better bet might be to hook the add_pageLoaded event of the PageRequestManager. This is an article that describes how to do it. Then put the jQuery stuff in a method and call it in the event.