Recalling JS functions on Partial Page Refresh
I am doing a partial page refresh on a div on my site. In that div I have some js functions I am calling to hide certain parts of the text. This is basically so you can click on an item and cause the hidden text to slide out using 开发者_开发问答jquery.
When I do the refresh, the hide() functions need to be called again which I am now doing with a callback function and I am using display:none for the css. When one clicks on an expand button I change the class to open. The problem is that the items aren't staying open when the div refreshes.
This is the page refresh:
setInterval(function() {
    $("#newsWrapper").load(location.href+" #newsWrapper");
}, 5000);
This is the click event that changes the class.
$('.expand').live('click', function (event) {
    $(this).parent().next().toggle('slide');
    imgName = $(this).html();
    //change plus to minus or vice-versa
    if (imgName == '<img src="images/plus.png">') {
        $(this).html('<img src="images/minus_sign.jpg">');
        $(this).parent().parent().children('.news_detail').addClass('open');
        $(this).parent().parent().children('.news_detail').removeClass('close');
    } else {
        $(this).html('<img src="images/plus.png">');
        $(this).parent().parent().children('.news_detail').addClass('close');
        $(this).parent().parent().children('.news_detail').removeClass('open');
    }
    event.preventDefault();
});
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论