2012-10-11 45 views
0

我目前在Confluence HTML宏內使用jQuery來顯示一個對話框。如何在Confluence中使用jQuery UI?

<input type="text" id="shortName" style="height: 18px; width: 50px;"> 
<input type="submit" id="submit" value="calendar"> 
<script type="text/javascript"> 
jQuery(document).ready(function() { 
    jQuery("#calendarDialog").dialog({ 
    modal: true, 
    autoOpen: false, 
    height: "600", 
    width: "800", 
    draggable: true, 
    resizeable: true 
    }); 
    jQuery("#submit").click(
    function() { 
     var emp = jQuery("#shortName").val().replace('.', ''); 
     var url = <some-url>; 
     var dialogTitle = emp + "'s day calendar"; 
     jQuery("#calendarDialog").dialog("open"); 
     jQuery("#calendarDialog").dialog("option", "title", dialogTitle); 
     jQuery("#calendarIFrame").attr("src", url); 
     return false; 
    }); 
    jQuery("#shortName").focus(); 
}); 
</script> 
<div id="calendarDialog" style="overflow: none;"><iframe id="calendarIFrame" width="100%" height="99%" frameBorder="0" title="dialogBox"></iframe></div> 

我該如何在Confluence中包含jQuery UI的東西?如果我在上面的代碼中引用了jQuery UI(引用http://code.jquery.com/ui/1.9.0/jquery-ui.js),它將打破宏中的jQuery代碼。

+0

請問您是否更具體?什麼語句在'jquery(document).ready(function(){...})'結構中不起作用? –

+0

@ Beetroot-Beetroot,我避免發佈整個代碼,因爲我認爲在這種情況下它是無關緊要的。我們的Confluence自帶jQuery 1.6.x,可能也可能不會發布jQuery UI,我不知道。在我的HTML宏中包含jQuery UI似乎會導致與Confluence或者Confluence中包含的JS庫的衝突。 –

+0

這可能只是使用英語,但你的聲明「如果我在上面的代碼中包含jQuery UI ......」有點令人擔憂。我只是想檢查你是不是在做一些愚蠢的事情。 –

回答

0

在Atlassian的-plugin.xml中:

<web-resource name="Resources" key="A-NAME-FOR-a-resource-key"> 
    <dependency>com.atlassian.auiplugin:ajs</dependency> 
    <resource type="download" name="jquery-ui.js" location="js/jquery-ui.js"/> 
    <resource type="download" name="jquery-ui.css" location="css/jquery-ui.css"/> 
</web-resource> 

在file_name.vm:

$webResourceManager.requireResource("A-NAME-FOR-a-resource-key") 

文件jQuery的ui.js和jQuery的ui.css應的資源文件夾下保存

相關問題