当我打开网站时,时间戳列表将加载Ajax。当我点击按钮< stop&gt ;,脚本时间戳/停止将被执行,列表将在Ajax之后重新加载。
但是,当我想第二次点击此列表到另一个停止按钮时,没有任何反应。
当我重新加载整个网站时,我可以再次删除一行。 当我删除一行到图标fa-refresh后点击时,也有可能删除一行。
但我怎样才能解决这个问题呢?
主要脚本:
<script>
$(document).ready(function() {
$.ajax({
type: "GET",
url: "timestamp/list-open-all",
data: "nachladen",
success: function(nachladen){
$('#nachladen').empty();
$('<span>'+nachladen+'</span>').appendTo('#nachladen');
}
});
$("#refresh-link-active-timestamps").click(function () {
console.log('Daten gespeichert');
$.ajax({
type: "GET",
url: "timestamp/list-open-all",
data: "nachladen",
success: function(nachladen){
$('#nachladen').empty();
$('<span>'+nachladen+'</span>').appendTo('#nachladen');
}
});
});
$("#button-timestamp-stop").click(function () {
console.log('Button Stop in aktivem Zeitstempel gedrückt');
var projectid = $("#button-timestamp-stop").attr('data-ts');
console.log(projectid);
$.ajax({
type: 'POST',
url: 'timestamp/stop/project/'+projectid,
data: 'testdata=1', //pass data1 to second request
success: function(data){
$.ajax({
type: "GET",
url: "timestamp/list-open-all",
data: "nachladen",
success: function(nachladen){
$('#nachladen').empty();
$('<span>'+nachladen+'</span>').appendTo('#nachladen');
}
});
}
});
});
});
</script>
时间戳/列表开放所有
<?php foreach($this->timestamps as $key => $value) { ?>
<div class="feed-element">
<a href="profile.html" class="pull-left">
<img alt="image" class="img-circle" src="img/profile/user/<?php echo $value['created_user'] ?>.jpg">
</a>
<div class="media-body ">
<div class="actions">
<a class="btn btn-xs btn-white" id="button-timestamp-stop" data-ts="<?php echo $value['id'] ?>"> stop </a>
</div>
</div>
</div>
<?php } ?>
答案 0 :(得分:0)
我找到了:
$(document).on("click", '#refresh-link-active-timestamps', function() {
而不是
$("#button-timestamp-stop").click(function () {