버튼이있는 .toggle
기능으로 표시되는 CSS 디스플레이 없음이있는 div가 있습니다.jQuery .load div inside toggle
해당 div에는 블로그 댓글이 포함되어 있습니다. 내가 새로운 코멘트를 보낼 때 .load
함수로 해당 div를 새로 고치지 만 표시하려면 버튼을 다시 클릭해야하므로 div를 토글합니다.
이 문제를 방지 할 수있는 방법이 있습니까?
CSS :
.comments-container {
width: 100%;
display: none;
}
HTML :
<div class="row" id="criticas-wrapper">
<h4 class="media-title" id="toggle_criticas" onclick="ver_criticas()">▼ CRÍTICAS</h4>
<button type="button" class="reply">Nuevo comentario</button>
<div class="comments-container">
// Here are all the comments
</div>
</div>
JS는 :
<script>
function ver_criticas() {
$(".comments-container").toggle("slow");
}
</script>
<script>
jQuery(document).on('submit', '.comment_form', function(e){
event.preventDefault();
$.ajax({
type: "POST",
url: $(this).attr("action"),
data: $(this).serialize(),
success:function(data){
var json = JSON.parse(data);
$(".errormensaje,.correctomensaje").html("").css({"display":"none"});
$("#comment").val("");
$('#parent_comment').val("");
if(json.resultado =="correcto"){
if(json.mensaje){
var notification = alertify.notify('¡Mensaje publicado!', 'success', 3, function(){ console.log('dismissed'); });
$('#criticas-wrapper').load('<?php echo base_url(uri_string());?> #criticas-wrapper');
}
}
if(json.resultado =="error"){
if(json.mensaje){
//$(".errormensaje").append(json.mensaje).css({"display":"block"});
var notification = alertify.notify(json.mensaje, 'error', 3, function(){ console.log('dismissed'); });
}
}
else
{
console.log(data);
}
},
error:function(xhr,exception)
{
}
})
e.preventDefault();
});
</script>
당신이하고있는 것을 보여 주면 좋을까요? – funcoding
코드를 표시해야합니까? 그렇지 않으면 어떻게 알릴 수 있습니까? – user3154108
짐작 컨데 부하가 div를 다시 숨기고 있다는 것입니다! 로드 한 후에는 이벤트를 트리거하여 표시해야합니다. 또는 CSS 표시 속성을 변경하십시오. – funcoding