대화 상자 내에서 jQuery 대화 상자를 닫는 방법은 무엇입니까?
닫기 버튼을 사용하지 않고 대화 상자 내에서 jQuery 대화 상자를 닫는 방법은 무엇입니까?
ui 대화 상자 내부에는 간단한 양식 요청이 있으며 제출이 성공하면 ui 대화 상자가 자동으로 닫히고 상위 페이지를 새로 고칩니다.
<script type="text/javascript">
$(document).ready(function () {
$("#form-dialog").dialog({
autoOpen: true,
modal: true,
width: 200,
draggable: true,
resizable: true
});
});
</script>
<div id="form-dialog" title="Form Submit">
<form action="default.aspx" method="post">
<input type="text" name="name" value=" " />
<input type="submit" value="submit" />
<a href="#" id="btnDone">CLOSE</a>
<script type="text/javascript">
$(document).ready(function () {
$("#btnDone").click(function () {
$(this).dialog('close');
});
});
</script>
</form>
</div>
-제국
이 시도
$(this).closest('.ui-dialog-content').dialog('close');
내부의 대화 상자가 닫힙니다.
프로그래밍 방식으로 닫을 수 있습니다.
$('#form-dialog').dialog('close')
당신이 원할 때마다.
당신은 필요합니다
$('selector').dialog('close');
대화 상자 내 iframe에서 닫기 :
window.parent.$('.ui-dialog-content:visible').dialog('close');
$(this).parents(".ui-dialog-content").dialog('close')
간단합니다. 다음을하지 않도록합니다.
- 하드 코드 대화 상자 #id 값.
- 모든 대화 상자를 닫습니다.
위의 모든 답변을 운없이 확인한 후 다음 코드가 문제를 해결하는 데 도움이되었습니다.
$(".ui-dialog").dialog("close");
대안을 찾는 경우에도 좋은 시도가 될 것입니다.
하나의 문자열을
$("#form-dialog").dialog('close');
여기서 $ (this)는 다른 객체를 의미합니다. $ ( "# btnDone")
<script type="text/javascript">
$(document).ready(function () {
$("#form-dialog").dialog({
autoOpen: true,
modal: true,
width: 200,
draggable: true,
resizable: true
});
});
</script>
<div id="form-dialog" title="Form Submit">
<form action="default.aspx" method="post">
<input type="text" name="name" value=" " />
<input type="submit" value="submit" />
<a href="#" id="btnDone">CLOSE</a>
<script type="text/javascript">
$(document).ready(function () {
$("#btnDone").click(function () {
//I've replaced next string
// $(this) here means another object $("#btnDone")
$("#form-dialog").dialog('close');
});
});
</script>
</form>
</div>
오픈에이 링크 추가
$(this).parent().appendTo($("form:first"));
완벽하게 작동합니다.
$(document).ready(function () {
$("#form-dialog").dialog({
autoOpen: true,
modal: true,
width: 200,
draggable: true,
resizable: true,
buttons: {
"Close": function () {
$("#idDialog").dialog("close");
}
}
});
});
This will make you a button to close. you can also call the function close
$("#idDialog").dialog("close");
in some function to do this. or even in a button/a
< a href="javascript:void(0);" id="btnDone"
onClick="$("#idDialog").dialog("close");">CLOSE</a>
EDIT: you need this to include your dialog into form:
open: function (type, data) {
$(this).parent().appendTo($("form:first"));
}
better way is "destroy and remove" instead of "close" it will remove dialog's "html" from the DOM
$(this).closest('.ui-dialog-content').dialog('destroy').remove();
Using $(this).dialog('close');
only works inside the click function of a button within the modal. If your button is not within the dialog box, as in this example, specify a selector:
$('#form-dialog').dialog('close');
For more information, see the documentation
참고URL : https://stackoverflow.com/questions/2933826/how-to-close-jquery-dialog-within-the-dialog
'Program Tip' 카테고리의 다른 글
ERRORLEVEL을 0으로 재설정하는 가장 쉬운 방법은 무엇입니까? (0) | 2020.11.16 |
---|---|
PowerShell의 명령 출력에 줄 바꿈을 추가하려면 어떻게해야합니까? (0) | 2020.11.16 |
문자열이 double로 구문 분석 가능한지 확인하는 방법은 무엇입니까? (0) | 2020.11.16 |
VC2010 C ++-소스 파일 구성 (0) | 2020.11.16 |
Serializable을 사용하여 인 텐트를 통해 데이터 전달 (0) | 2020.11.16 |