【问题标题】:Jquery in XPages not working properlyXPages 中的 Jquery 无法正常工作
【发布时间】:2014-08-05 13:24:00
【问题描述】:

我有一个 xpage,我在其中添加了 jquery 作为脚本资源。然后我添加了一些控件(使用 jquery 函数编辑、计算、输出脚本),我正在尝试一些虚拟的东西。看看我下面的xpage:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:this.resources>
        <xp:script src="http://code.jquery.com/jquery-1.10.2.js"
            clientSide="true">
        </xp:script>
        <xp:script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"
            clientSide="true">
        </xp:script>
        <xp:styleSheet
            href="http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
        </xp:styleSheet>
    </xp:this.resources>

    <xp:scriptBlock id="scriptBlock1">
        <xp:this.value><![CDATA[$(document).ready(function() {
  $("#{id:button1}").mouseover(function() {
      alert('sdfsdfsdf');
  });
});]]></xp:this.value>
    </xp:scriptBlock>
    <xp:br></xp:br>
    <xp:br></xp:br>    
    <xp:button value="Label" id="button1"></xp:button>
    <xp:br></xp:br>
    <xp:br></xp:br>
    <xp:text escape="false" id="ttt">
        <xp:this.value><![CDATA[#{javascript:"<p id='test'>sdfsdfsdf</p>"}]]></xp:this.value>
    </xp:text>
</xp:view>

当我悬停按钮时,没有任何反应。如果我将鼠标悬停的 id 设置为 #test 则它可以工作。

在XPages中使用jquery有什么问题?

【问题讨论】:

  • 还可以考虑使用类选择器而不是 id 选择器。
  • 我总是使用类选择器来避免生成奇怪的 id。

标签: javascript jquery xpages lotus-notes lotus-domino


【解决方案1】:

使用来自 openntf 的x$ jQuery selector for XPages sn-p 或使用

$("[id$='#{id:button1}']").mouseover(function() {...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-13
    • 2011-07-24
    • 1970-01-01
    • 1970-01-01
    • 2021-06-16
    • 2015-12-14
    • 2015-11-13
    相关资源
    最近更新 更多