我正在编写一个程序,其中单击事件处理程序向我的节点服务器触发 ajax 请求,然后在把手部分中呈现信息并将其发送回客户端(res.render("partials/scraped-article", data);
)。客户端 javascript 将此 html 附加到文档并使用 bootstrap .modal("show") 函数显示模式。该程序在第一次触发 click 事件处理程序时显示模式,但之后不识别 .modal("show") 函数。有没有办法来解决这个问题?
客户端Javascript:
$(document).on("click", "#scrape-options li", function(){
var choice = $(this).text();
var request;
if(choice === "website1")
request = "/scrape/website1";
else
request = "/scrape/website2";
$.ajax({
type: "GET",
url: request
}).then(function(response){
$(".news-article").remove();
$("footer").append(response);
$('.news-article-img').each(function(i, element){
$(this).css({'height': ($(this).next().height() + 'px')});
});
$("footer h1").addClass("display-none");
$("#articles-added").text($(".news-article").length);
$(".modal").modal("show");
});
});