내 사이트의 페이지가 매 15 초마다 자동으로 다시로드됩니다. 그것은 jQuery의 .ajax 함수를 사용하여 수행되고 있습니다.jQuery 대화 상자 및 아약스 포스트 백
내 문제는 페이지가 사용자에 의해로드 될 때마다 대화 상자의 양식이 제대로 작동한다는 것입니다. 하지만 페이지 자체에서 자동으로 다시로드되면 입력이 양식 바깥쪽으로 이동됩니다.
많은 사람들이 인터넷에 글을 올리면서 발견 된 첫 번째 양식에 div를 추가하여 양식으로 다시 옮길 수 있다고합니다. 내 문제는, 내가 "input-wrapper"를 폼으로 옮기려고 할 때, 나는 이상한 문제가 발생한다는 것이다.
아무도 도와 줄 수 있습니까? 아니면 대체 솔루션을 지적하십시오.
내 jQuery를 스크립트 :
<script type='text/javascript'>
var intval;
var xmlhttp;
function init() {
$('#dialog:ui-dialog').dialog('destroy');
$('.ui-dialog').dialog({ modal: true, draggable: false, resizable: false, autoOpen: false, open: function(event, ui) { stopTimer(); }, close: function(event, ui) { startTimer(); } });
$('#targets').dialog({ width: 400, buttons: { 'close': { text: 'Luk', height: '30px', click: function() { $(this).dialog('close'); } }, 'submit': { text: 'OK', class: 'submit', height: '30px', click: function() { $(this).find('form').trigger('submit'); } } } });
$('#targets" & id2 & "Opener').click(function() { $('#targets').dialog('open'); return false; });
};
function startTimer() { intval = setTimeout('ajaxRefresh()', 15000); };
function stopTimer() { clearTimeout(intval); if(xmlhttp) xmlhttp.abort(); };
function ajaxRefresh() { xmlhttp = $.ajax({ url: '/', data: {h: 'ok'}, beforeSend: function() { stopTimer(); }, success: function(result) { $('body').html(result); } } }) };
$(document).ready(function() { init(); startTimer(); $('#targetsFormWrap').parent().appendTo('#targetsForm'); });
</script>
html로 : 당신이 바로 targetsForm하는 targetFormWrap을 추가하려고
<div id='targets' class='ui-dialog' title='The Dialog Title' style='text-align: center; display: none;'>
<form id='targetsForm' name='targetsForm' method='post'>")
<div id='targetsFormWrap'>")
<input id='input1target' name='input1target' type='text' value='' style='width: 95%; />
<input id='input2target' name='input2target' type='text' value='' style='width: 95%; />
<input id='input3target' name='input3target' type='text' value='' style='width: 95%; />
</div>
</form>
</div>
.appendTo() 대신 시도한 .append()를 사용 했습니까? – orolo
Evan이 그의 대답에서 말했듯이, 나는 그곳에서 해설 했으므로 작업을하지 못했습니다 :/ – Behrens