Jquery- reload doesnt occur if clicked second time

74 views Asked by At
<li id="rpt21" align=left><a  class="keepopen" href="#">Trade List Buys</a></li>

If i click on the above link 'Trade List Buys', the list gets loaded in the right side of the screen. however, when i click again while on the same page, it doesnt reload the data on right side. it looks static. How can i ensure that it reloads every time i click.

Below is the rpt21 function which gets executed.

$("#rpt21 a.keepopen").click(function() {
    $("#report_panel").hide();
    $("#report_header").hide();
    $("#report_panel_alldata").hide();
    $("#report_header_alldata").hide();
    var rmanager = $("#rmanager").val();
    var manager = $("#manager").val();
    var account = $("#account").val();
    var folderdate = $("#folderdate").val();
    var pricedate = $("#pricedate").val();;
    x = getDataForRpt(rmanager, manager, account, folderdate, pricedate, "buy_list", "D:\\web\\webtmp", "post_op_rpt_20150617_4700.html", "runRpt");
    $("#report_panel").show();
});
1

There are 1 answers

0
Satpal On

It is working first time not after that, This can happen if you are recreating the DOM elements.

In this scenario you can use Event Delegation.

$(document).on('click', "#rpt21 a.keepopen", function(){
    //Your code
});