jqueryui 웹 사이트에서이 예제와 매우 비슷한 것을 복제하려고하는데, 실제로 jqueryui 웹 사이트에서 매우 기본적인 간단한 대화 상자를 만들려고합니다.Jetpack에서 jQuery UI의 대화 상자 기능을 복제하는 방법은 무엇입니까?
<script type="text/javascript">
$(function() {
$("#dialog").dialog({
bgiframe: true,
height: 140,
modal: true
});
});
</script>
<div class="demo">
<div id="dialog" title="Basic modal dialog">
<p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
</div>
...
순서대로 이것을 달성하기 위해 함수 testJQ를 실행하지만 원하는 효과를 얻을 수 없습니다. div와 내부 p가 추가되어 p의 내용을 볼 수 있지만 "기본 모달 대화 상자"가 표시되지 않고 페이지 주위로 이동할 수 없습니다. 내가 놓친 게 있니? 여기 내 코드가 있습니다 :
function testJQ() {
var doc = jetpack.tabs.focused.contentDocument;
var win = jetpack.tabs.focused.contentWindow;
$.get("http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js",
function(js) {
var script = doc.createElement("script");
script.innerHTML = js;
doc.body.appendChild(script);
$.get("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js",
function(js) {
var script = doc.createElement("script");
script.innerHTML = js;
doc.body.appendChild(script);
$.get("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css",
function(js) {
var style = doc.createElement("style");
style.innerHTML = js;
doc.getElementsByTagName('HEAD')[0].appendChild(style);
var script = doc.createElement("script");
script.innerHTML = js;
doc.body.appendChild(script);
script = doc.createElement("script");
script.innerHTML += '$(function() {';
script.innerHTML += '$("#dialog").dialog({'
script.innerHTML += ' bgiframe: true, height: 140, modal: true';
script.innerHTML += ' });';
script.innerHTML += '});';
doc.body.appendChild(script);
divDialog = doc.createElement("div");
divDialog.setAttribute('id', 'dialog');
divDialog.setAttribute('title', 'Basic Dialog');
divDialog.innerHTML = '<p>This is the default dialog which is useful
for displaying information. The dialog window can be moved, resized
and closed with the X icon.</p>';
doc.body.appendChild(divDialog);
});
});
});
}
나는 순서의 변경을 삽입, 이제 divDialog, doc.body.appendChild (divDialog);를 삽입합니다. 그런 다음 스크립트 요소를 생성하고 삽입하십시오. doc.body.appendChild (script); 그러나 보이는 효과는 동일합니다. 방금 p 요소의 내용이 표시됩니다. 대화 제목이 표시되지 않거나 끌 수 없습니다. 추가로 Firebug가 "구문 오류 : .ui-helper-hidden {display : none;} \ n"이라고 말합니다. \ n " jquery, ui를 설치하고 이미"대화 상자 "라는 ID로 elemement를 확인하는 것에 대해 우려하고 있습니다. 위험을 감수해야하고, 일단 이것이 작동하게되면 필요한 예방 조치를 취할 것입니다. –
'