我在计时器上有一个AJAX请求(每5秒钟):
function getAvisierung(){
$.ajax({
url: 'content/ajax.php',
type: 'GET',
data: { get_item: 'get_avis', page: 'Advice'},
success: function(data){
var obj = JSON.parse(data);
$("#avis_content").html('');
for(var x=0; x<obj.length; x++){
$("#avis_content").append('<a href="#" data-original-title="Test" data-toggle="tooltip" data-placement="top"><i class="fa fa-pencil"></i></a><a class="modal-basic delete_item" href="#deleteAvis" data-id="id" data-original-title="Löschen" data-toggle="tooltip" data-placement="top"><i class="fa fa-trash-o"></i></a>');
}
}
});
}
但是href
对我的模态对话框和工具提示不起作用。有什么想法吗?
当我只使用HTML时 - 它有效。当它在AJAX请求中时 - 它没有。
答案 0 :(得分:0)
AJAX
$('[data-toggle="ajaxModal"]').on('click',
function(e) {
$('#ajaxModal').remove();
e.preventDefault();
var $this = $(this)
, $remote = $this.data('remote') || $this.attr('href')
, $modal = $('<div class="modal" id="ajaxModal"><div class="modal-body"></div></div>');
$('body').append($modal);
$modal.modal({backdrop: 'static', keyboard: false});
$modal.load($remote);
}
);
HTML
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">× </button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<a href="#" class="btn btn-white" data-dismiss="modal">Close</a>
<a href="#" class="btn btn-primary">Button</a>
<a href="#" class="btn btn-primary">Another button...</a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->