简体   繁体   中英

javascript execute on dynamically downloaded html

I believe I've seen this somewhere but the past 30 minutes of google searching has not yielded an acceptable answer.

I'm using Bootstrap to generate a popover. I'm downloaded a table into a div using:

$(document).ready(function() {
  $('#jobTable').load('./includes/job_table.inc.php');
  $('#commpop').popover({trigger: 'hover'});
  setInterval(function() {
    $('#jobTable').load('./includes/job_table.inc.php');
    $('#jobTable #commpop').popover({trigger: 'hover'});
  }, 5000);//end reload
});//end load

This executes fine on the:

<a href="#" class="btn btn-success" id="commpop" rel="popover"
data-content="I'm working!" data-original-title="Further Details">hey you!</a> 

Which exists within my base php file, but does not work on an identical statement placed within the <div id="jobTable"></div> which is dynamically downloaded.

How do I apply this to that div as well? You can see my attempt above is not working...

EDIT: Yes, the $('#jobTable').load('./includes/job_table.inc.php'); is the jQuery AJAX statement I'm using to download and then periodically refresh the table.

$(document).ready(function() {
  $('#jobTable').load('./includes/job_table.inc.php', function() {
  alert('Load was performed.');
// do all your work here
});

});//end load

我想使用上面的答案,但不是定义像'./includes/job_table.inc.php'这样的部分路径,而是定义完整路径,这可能会有所帮助!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM