bPopup
을 사용하여 인라인 팝업을 시작합니다. http://dinbror.dk/blog/bPopup/여러 jquery 인라인 모달 팝업
어떤 링크를 클릭했는지에 따라 여러 가지 인라인 팝업을 시작할 수 있어야하는 페이지가 있습니다. 하지만 bPopup
의 기본 코드는 매우 비효율적이며 같은 페이지에서 여러 가지 인라인 팝업을 허용하는 다른 플러그인을 찾을 수 없습니다.
자바 스크립트 : 여기
코드입니다// Semicolon (;) to ensure closing of earlier scripting
// Encapsulation
// $ is assigned to jQuery
;(function($) {
// DOM Ready
$(function() {
// Binding a click event
// From jQuery v.1.7.0 use .on() instead of .bind()
$('#my-button').bind('click', function(e) {
// Prevents the default action to be triggered.
e.preventDefault();
// Triggering bPopup when click event is fired
$('#element_to_pop_up').bPopup();
});
// Binding a click event
// From jQuery v.1.7.0 use .on() instead of .bind()
$('#my-button2').bind('click', function(e) {
// Prevents the default action to be triggered.
e.preventDefault();
// Triggering bPopup when click event is fired
$('#element_to_pop_up2').bPopup();
});
})(jQuery);
HTML : I 각 버튼에 대해 다른 이벤트를 만들 필요가 있기 때문에 그것은 효율적이지 않습니다
<div id="my-button">
<div id="element_to_pop_up">Content of popup</div>
</div>
<div id="my-button2">
<div id="element_to_pop_up2">Content of popup2</div>
</div>
, 각 버튼에 대한 새로운 ID 및 각 팝업에 대한 새로운 ID
.
바인드 대신 .on()
을 사용하는 것에 대해 읽었습니다. 그러나 나는 거기에서 어디로 가야할지 모르겠습니다.