미채택 완료

ajax 댓글 적용시 버튼 클릭안되는 현상 문의

2020-12-01 (화) 14:21:53 1,876

아래와 같이 ajax로 새로고침 없이 댓글 등록인데요.


작동은 잘되는데 문제는 ajaxcomment부분만 새로고침하니 버튼이 클릭이안되네요.
전체페이지 새로고침하면 버튼 클릭이됩니다.

전체페이지 새로고침 안해도 버튼이 클릭이되게 할순 없을까요?

Copy
<ajaxcomment>
댓글 내용들...
<div class="bo_vl_opt">
<button type="button" class="btn_cm_opt btn_b01 btn"><span class="sound_only">댓글 옵션</span></button>
<ul class="bo_vc_act">
버튼...
</ul>
</div>
</ajaxcomment>

그누보드 원본 스크립트

Copy
<script>
$(function() {                
// 댓글 옵션창 열기
$(".btn_cm_opt").on("click", function(){
$(this).parent("div").children(".bo_vc_act").show();
});
                
// 댓글 옵션창 닫기
$(document).mouseup(function (e){
var container = $(".bo_vc_act");
if( container.has(e.target).length === 0)
container.hide();
});
});
</script>

예전 군포돼지님께서 알려주신건데 첨엔 되는듯 하더니 안되네요.

Copy
<script>
$(function() {
// 댓글 옵션창 열기
$(document).on("click", ".btn_cm_opt", function(){
$(this).parent("div").children(".bo_vc_act").show();
});

// 댓글 옵션창 닫기
$(document).mouseup(function (e){
var container = $(".bo_vc_act");
if( container.has(e.target).length === 0)
container.hide();
});
});
</script>

ajax 코드

Copy
$.ajax({
        url: f.action,
        type: 'POST',
        data: $(f).serialize(),
        dataType: 'html',
    })
    .done(function(aposs) {
        var tempDom = $('<output>').append($.parseHTML(aposs))
        var title = $('title', tempDom).text()
        if (title === '') {
            // 1. commentBox 원위치
            comment_box('', '', 'c')

            // 2. commentBox Form 리셋
            f.reset()
            
            // 3. 코멘트 출력
            $.ajax({
                url: aposs,
                type: 'GET',
                dataType: 'html'
            })
            .done(function(aposs2) {
                var tempDom2 = $('<output>').append($.parseHTML(aposs2))
                $('ajaxcomment').replaceWith($('ajaxcomment', tempDom2))
            })
        }
        document.getElementById("btn_submit").disabled = ""
    })
|

답변 2개 / 댓글 2개

2020-12-01 (화) 19:18:45

document.getElementById("btn_submit").disabled = ""

코드를 삭제하면 될 듯 합니다.

답변에 대한 댓글 1개

@마르스컴퍼니 님 댓글 감사합니다.
알려주신대로 삭제를해도 깔끔하게는 안되네요.
그누보드 원본 코드는 아예안되고요.
위에 군포돼지님 코드로하면
첫번째는 무조건 안되고 새로고침 이후
두번째 댓글부턴 새로고침없이도 클릭이되네요
2020-12-01 (화) 15:05:02

개발자도구에서 콘솔에 에러나는게있는지 확인해보세요

답변에 대한 댓글 1개

관련 에러는 없어요~

답변을 작성하려면 로그인이 필요합니다.