问题描述
当在muuri.js或jQuery UI中拖动div时,div将获得“拖动”类。 如何停止事件侦听器运行createHTML();拖动时放开div后是否起作用?我希望单击仅在快速单击后运行功能,而在按住并拖动时不运行。
var loadContentButton = document.getElementById("load-content-button-<?php echo get_the_ID(); ?>");
var loadContentContainer = document.getElementById("content-pop-up");
var loadContentContainerWrap = document.getElementById("pop-up");
if (loadContentButton) {
loadContentButton.addEventListener("click",function() {
var ourRequest = new XMLHttpRequest();
ourRequest.open('GET','http://example.com/wp-json/wp/v2/posts/<?php echo get_the_ID(); ?>');
ourRequest.onload = function() {
if (ourRequest.status >= 200 && ourRequest.status < 400) {
var data = JSON.parse(ourRequest.responseText);
console.log(data);
createHTML(data);
loadContentContainerWrap.classList.add("active-pop-up-main");
} else {
console.log("We connected to the server,but it returned an error.");
}
};
ourRequest.onerror = function() {
console.log("Connection error");
};
ourRequest.send();
});
}
function createHTML(postsData) {
var ourHTMLString = '';
ourHTMLString += '<h2>' + postsData.title.rendered + '</h2>';
ourHTMLString += postsData.content.rendered;
loadContentContainer.innerHTML = ourHTMLString;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)