작업이 JQuery와 팝업 메뉴 스크립트를 수정해야 - 당신이 스크립트를 호출하는만큼.나는에서이 스크립트를 사용하고 아약스
팝업이 이미 설정된 경우 실행되지 않도록하는 방법을 알아 내려고하고 있습니다. 다음 스크립트는 다음과 같습니다
//
// pop! for jQuery
// v0.2 requires jQuery v1.2 or later
//
// Licensed under the MIT:
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright 2007,2008 SEAOFCLOUDS [http://seaofclouds.com]
//
(function($) {
$.pop = function(options){
// inject html wrapper
function initpops(){
$(".pop").each(function() {
var pop_classes = $(this).attr("class");
if ($(this).find('.pop_menu').length) {
// do nothing
} else {
$(this).addClass("pop_menu");
$(this).wrap("<div class='"+pop_classes+"'></div>");
$(".pop_menu").attr("class", "pop_menu");
$(this).before(" \
<div class='pop_toggle'></div> \
");
}
});
}
initpops();
// assign reverse z-indexes to each pop
var totalpops = $(".pop").length + 100;
$(".pop").each(function(i) {
var popzindex = totalpops - i;
$(this).css({ zIndex: popzindex });
});
// close pops if user clicks outside of pop
activePop = null;
function closeInactivePop() {
$(".pop").each(function (i) {
if ($(this).hasClass('active') && i!=activePop) {
$(this).removeClass('active');
}
});
return false;
}
$(".pop").mouseover(function() { activePop = $(".pop").index(this); });
$(".pop").mouseout(function() { activePop = null; });
$("body").on("click", ".pop", function(){
closeInactivePop();
});
// toggle that pop
$("body").on("click", ".pop_toggle", function(){
$(this).parent(".pop").toggleClass("active");
});
}
})(jQuery);
을 지금 내가 전화 새로운 팝 아웃 메뉴 작업을 아약스에서이 스크립트를로드하지만, 오래된 것들은 onclick 이벤트에 반응하지 않는 경우.
것은 내가 그 다른 새로운 요소를 활성화 팝 이벤트를 트리거 할 필요가 그래서 새로운 .pop 요소를 호출하는 아약스를 사용하고 있습니다. 나는 플러그인이 그것을 위해 설계되지 않았 음을 이해합니다. 그래서 코드를 적절하게 수정해야합니다. –
수정하지 마십시오. 그럴 가치가 없어. 지정된 요소에 고정시킬 수있는 것을 훨씬 쉽게 작성할 수 있습니다. .pop_ready와 같은 클래스를 하나 더 추가 할 수도 있습니다. 클래스를 만들면 .pop 클래스가 .pop_ready로 변경됩니다. 그러면 다음 init 이후에 다시 렌더링되지 않습니다. 많은 작업이 아닙니다. :) – imclickingmaniac