$ ( '#idfield'). val () jQuery 대화 상자 내부
-
22-07-2019 - |
문제
jQuery 대화 상자 내부에있는 항목 ID에서 다음 jQuery 함수를 사용할 수 있는지 알고 싶습니다.
$('#idofmyfield').val()
아무것도 돌려주지 않았습니다.
해결책
대화 상자에 의해 생성 된 마크 업으로 선택기 ID를 조정해야 할 수도 있습니다.
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable">
<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
<span id="ui-dialog-title-dialog" class="ui-dialog-title">Dialog title</span>
<a class="ui-dialog-titlebar-close ui-corner-all" href="#"><span class="ui-icon ui-icon-closethick">close</span></a>
</div>
<div style="height: 200px; min-height: 109px; width: auto;" class="ui-dialog-content ui-widget-content" id="dialog">
<p>Dialog content goes here.</p>
</div>
</div>
아마 이것을 할 수 있습니다 :
$('div.ui-widget-content > #idofmyfield').val();
대화 상자를 채우기 위해 JSON 데이터를 가져 오는 비슷한 상황이있었습니다. 작동하는 내 코드는 다음과 같습니다.
if (jQuery) {
jQuery(document).ready(function(){
jQuery('#dialog').dialog({
autoOpen: false,
modal: true,
width: 690,
position: [160, 160]
}); /* end #dialog */
/* do some processing and add the following to a click method */
jQuery.getJSON(json_link, function(json){
jQuery('.ui-dialog-title').text(json.title);
jQuery('.ui-dialog-content').html(json.html);
});
jQuery('#dialog').dialog('open');
/* end of click method */
}); /* end document.ready */
}
다른 팁
$('.yourDialog').dialog({
close: function(event, ui) {
alert($('#idofmyfield').val());
}
});
제휴하지 않습니다 StackOverflow