简体   繁体   English

jQuery cluetip:渲染后处理内容

[英]jQuery cluetip: Manipulate content after rendering

I may be stating this incorrectly, but is there any way to manipulate (using JavaScript) the content in an cluetip once the content has been (dynamically) loaded to the external .jsp? 我可能没有正确地说明这一点,但是一旦内容(动态)加载到外部.jsp中,是否有任何方法可以操纵(使用JavaScript)提示中的内容?

I have a list of items being displayed, and I want to bold some of them. 我有一个要显示的项目列表,我想将其中一些加粗。 I cannot add ID's or classes individually to any of these items in the list, prior to rendering. 在渲染之前,我无法将ID或类单独添加到列表中的任何这些项目中。 It's basically a data dump 基本上是数据转储

FYI, we're using JSF to pull the items on the .jsp, which are rendered in HTML as a table: 仅供参考,我们正在使用JSF在.jsp上提取项目,这些项目以HTML形式呈现为表格:

<h:panelGrid columns="1">
    <h:column>
        <h:selectManyCheckbox layout="pageDirection" value="#{advancedtoolscontroller.roleItems}">
            <f:selectItems value="#{advancedtoolscontroller.roleList}" />
        </h:selectManyCheckbox>
    </h:column>
</h:panelGrid>  

Any help is greatly appreciated... 任何帮助是极大的赞赏...

You need to assign the h:selectManyCheckbox and any parent UINamingContainer components (eg h:form , h:dataTable , etc) an unique ID. 您需要为h:selectManyCheckbox和任何父UINamingContainer组件(例如h:formh:dataTable等)分配唯一的 ID。 This way JSF will generate the client ID's accordingly, otherwise it will autogenerate unpredictable client ID's which you cannot use in JS. 这样,JSF将相应地生成客户机ID,否则它将自动生成无法在JS中使用的不可预测的客户机ID。 To find out how they have been generated, just rightclick the page in webbrowser and choose View Source . 要了解它们是如何生成的,只需在webbrowser中的页面上单击鼠标右键,然后选择“ 查看源代码”

There's however one small caveat, JSF uses the colon : as UINamingContainer separator, eg formid:checkboxid . 但是有一个小警告,JSF使用冒号:作为UINamingContainer分隔符,例如formid:checkboxid The colon is an illegal character in CSS. 冒号是CSS中的非法字符。 To select them in CSS/jQuery anyway, you need to escape them with a backslash. 无论如何要在CSS / jQuery中选择它们,您需要使用反斜杠将其转义。 Eg formid\\:checkboxid . 例如: formid\\:checkboxid

Besides, the h:dataTable will append one more identifier to the client ID after the datatable ID, namely the row index, eg formid:datatableid:0:checkboxid . 此外, h:dataTable将在数据表ID后面的客户端ID后附加一个标识符,即行索引,例如formid:datatableid:0:checkboxid But that should look obvious enough when you see the patterns in the generated HTML output. 但是,当您在生成的HTML输出中看到模式时,这看起来应该足够明显。

The h:selectManyCheckbox on its turn assigns every checkbox an unique client ID and the same client name. h:selectManyCheckbox依次为每个复选框分配唯一的客户端ID和相同的客户端名称。 Again, just check the generated HTML output to see the patterns. 同样,只需检查生成的HTML输出以查看模式。

In jQuery you could also use the jQuery.filter() to filter out checkboxes of interest based on the last part of their client ID/name. 在jQuery中,您还可以使用jQuery.filter()来根据客户端ID /名称的最后一部分过滤出所需的复选框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM