有关同时使用 jQuery 和 Dojo 的提示,请参阅https://www.ibm.com/developerworks/community/blogs/94e7fded-7162-445e-8ceb-97a2140866a9/entry/loading_jquery_with_dojo_1_7_amd_loader2?lang=en
对于 xPages:添加到 XSP 属性:
xsp.client.script.dojo.djConfig=async:true
创建一个包含以下内容的脚本库:
define.amd.jQuery = true;
并将其作为资源添加到您的 xPage 中。
下面是 xPage 代码:
<xp:this.properties>
<xp:parameter name="xsp.client.script.dojo.djConfig" value="packages: exPackages" />
</xp:this.properties>
<xp:this.beforePageLoad>
<![CDATA[#{javascript:
var exCon = facesContext.getExternalContext();
var response = exCon.getResponse();
var writer = response.getWriter();
writer.write("<script>\n");
writer.write("var exPackages=[{name:'jquery',location:'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1',main:'jquery'}]\n");
writer.write("</script>\n");
}]]>
</xp:this.beforePageLoad>
<xp:this.resources>
<xp:script src="/jquery.js" clientSide="true"></xp:script>
<xp:dojoModule name="jquery"></xp:dojoModule>
</xp:this.resources><p id="test">Egor Margineanu</p>
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[alert($("#test").text());]]></xp:this.script>
</xp:eventHandler></xp:button>