사용자가 대화 상자를 닫을 때 대화 상자에서 텍스트를 제거하려고합니다. 한 페이지에 여러 개의 대화 상자가 있고 일부 대화 상자에는 대화 상자가 있습니다. 그 중 하나는 사용자에게 메시지를 보내고 다른 하나는 사용자 세부 정보를 업데이트하는 양식입니다.닫을 때 선택한 요소/텍스트를 대화 상자에서 어떻게 제거합니까?
양식이 제출되면 상태에 대한 양식 위에 메시지가 표시됩니다 (즉, 실패했는지 또는 성공했는지).
jQuery를 :
$('form.updateDetailsForm').on('submit', function()
{
//console.log("hello");
event.preventDefault();
var form = $(this);
post = form.serialize();
$.post("",{ form: post, studentHub: true}, function(msg)
{
var popUpDialog = form.parent();
console.log(msg);
var status = $('.notifications', popUpDialog);
status
.html(msg)
.hide()
.fadeTo(2500, 1)
.delay(20000)//<== wait 3 sec before fading out
.fadeTo(2000, 0, function()
{
status.html('');
});
});
//return false;
});//END OF updatedetails form submit
/****For each popuplink we bind the dialog that is ---IMMEDIATELY NEXT--- to it and click event to it. ***/
$('.popUpLink').each(function()
{
if(!$.data(this, 'dialog'))//if not bound then we bind it. This is for dynamic issues
{
$divDialog = $(this).next('.popUpDialog');
$.data(this, 'dialog', $divDialog.dialog(
{
autoOpen: false,
modal: true,
minWidth: '100',
width: '800',
hide: 'fold',
show: 'drop',
title: $divDialog.attr('title'),
close: function() {
$('.notifications, div:animated', $divDialog).html(''); //this is what I've tried but it doesn't work.
}
}));
}
}).on('click',function()
{
$.data(this, 'dialog').dialog('open').css('maxHeight', $(window).height()-90);
return false;
});
HTML :
<div class="flexi_box">
<h2 class="sendMessageHeader hubFormHeader">Send a message to your tutor </h2>
<div class="notifications"></div> //div to insert status updates
<form class="sendMessageForm" id="tutorForm" action="" method="POST">
<fieldset>
<textarea class="messageArea" name="message"></textarea>
<input type="submit" value="Send Message" class="cap_button hubSubmit">
</fieldset>
</form>
</div>
내 문제가 상태 업데이트가 여전히 내가 대화 상자를 다시 열 때 점이다.
당신은 지금 무엇이 문제인지 질문 했습니까? – j08691
죄송합니다, 완전하게 잊어 버렸습니다. –
'$ ('. notifications') .text ('');'와 같이 닫히면 모든 알림을 한꺼번에 비워 두시겠습니까, 아니면이 과도한 단순화입니까? "$ ('. notifications', $ divDialog) .text ('');' –