이럴 땐 어떻게 해야 하나요? <?php echo $list[$i]['subject'] ?> 를 한개뿐이 못읽는 코드(?)

이럴 땐 어떻게 해야 하나요? <?php echo $list[$i]['subject'] ?> 를 한개뿐이 못읽는 코드(?)

QA

이럴 땐 어떻게 해야 하나요? <?php echo $list[$i]['subject'] ?> 를 한개뿐이 못읽는 코드(?)

본문

        <style>
            #modal {
                position:absolute;
                background:gray;
                padding:8px;
        z-index: 10;
            }

            #content {
                background:white;
                padding:20px;
            }

            #close {
                position:absolute;
                background:url(close.png);
                width:24px;
                height:27px;
                top:0px;
                right:0px;
            }
        </style>
        <script>
            var modal = (function(){
                // Generate the HTML and add it to the document
                $modal = $('<div id="modal"></div>');
                $content = $('<div id="content"></div>');
                $close = $('<a id="close" href="#"><font size="4"><b>X</b></font></a>');

                $modal.hide();
                $modal.append($content, $close);

                $(document).ready(function(){
                    $('body').append($modal);                       
                });

                $close.click(function(e){
                    e.preventDefault();
                    $modal.hide();
                    $content.empty();
                });
                // Open the modal
                return function (content) {
                    $content.html(content);
                    // Center the modal in the viewport
                    $modal.css({
                        top: event.pageY,
                        left: event.pageX
                    });
                    $modal.show();
                };
            }());

            // Wait until the DOM has loaded before querying the document
            $(document).ready(function(){
                $('a#popup').click(function(e){
                    modal("<a href=\"https://direct.xxx.co.kr/xxx_dd1.php?search=<?php echo $list[$i]['subject'] ?>\" target=\"_blank\"><img src='/img/8.gif'></a><p style='display: block; margin: 10px 0;'></p><a href=\"https://direct.xxx.co.kr/xxx_dd2.php?search=<?php echo $list[$i]['subject'] ?>\" target=\"_blank\"><img src='/img/9.gif'></a><p style='display: block; margin: 10px 0;'></p><a href=\"https://direct.xxx.co.kr/xxx_dd3.php?search=<?php echo $list[$i]['subject'] ?>\" target=\"_blank\"><img src='/img/10.gif'></a>");
                    e.preventDefault();
                });
            });
        </script>

 

모달창 소스입니다.

 

                    modal("<a href=\"https://direct.xxx.co.kr/xxx_dd1.php?search=<?php echo $list[$i]['subject'] ?>\" target=\"_blank\"><img src='/img/8.gif'></a><p style='display: block; margin: 10px 0;'></p><a href=\"https://direct.xxx.co.kr/xxx_dd2.php?search=<?php echo $list[$i]['subject'] ?>\" target=\"_blank\"><img src='/img/9.gif'></a><p style='display: block; margin: 10px 0;'></p><a href=\"https://direct.xxx.co.kr/xxx_dd3.php?search=<?php echo $list[$i]['subject'] ?>\" target=\"_blank\"><img src='/img/10.gif'></a>");

 

문제는 여기에 있는데요. 각 게시물마다 <?php echo $list[$i]['subject'] ?> 이 코드가 다르게 읽어야 하는데 가장 하단에 있는 게시물의 제목만 읽습니다.

이럴때는 어떻게 해야 하나요?

이해가 안가는건 id="popup" 이 각 게시물마다 적용되는데 왜 한개뿐이 못읽는지 모르겠어요.

누가 해결 좀 해주세요~

이 질문에 댓글 쓰기 :

답변 5

id 는 고유한 값 입니다.

class 로 변경해보세요.

 

리스트에서 모달 불러올때는 각각 아이디를 줘야하고 그게 클릭으로 각각 아이디로 모달에 연결되야 합니다

리스트에서 모달적용하고 ajax로 업데이트하는거는 장난아니더군요,,ㅋ

그래서 저는 1)불러올 php는 별도 php페이지로 넣어놓고,물론 여기에 모달 css도 넣고.

모달클릭하면 아자씬가 하는거로 불러오는 식으로 햇어요,,,

그래하니 어떤 모달은 리스트에서 또 클릭이 안되더군요,, 그래서 불러올때 별도의 php에 다큐먼트 레이 어쩌구안에 trigger를 넣어 모달이 클릭되게 했어요,,그러니 정상작동하더군요,,ㅋㅋ

이상 그누x초딩이었습니다

답변을 작성하시기 전에 로그인 해주세요.
전체 934
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT