getNetuiTagName

本文介绍了 netUI 中 getNetuiTagName 标签的使用方法,该标签用于获取 tagId 属性值,即使在 Portal 应用中 tagId 被重写也能确保正确引用。文章还展示了如何通过 JavaScript 函数 getNetuiTagName 查询实际渲染的 ID,并提供了示例代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

<netui:getNetuiTagName> Tag

Returns the value of the tagId attribute.

Syntax

<netui:getNetuiTagName
    [id="id"]
    tagId="string_tagId" />

Description

Returns the value of the tagId attribute. This tag allows you to track the value of the tagId attribute, the value of which will be re-written if the web application is part of a Portal application. This tag is especially useful when you need to pass the tagId value to an HTML tag, or to some other tag that is not within the <netui...> tag library. In the following example, the tagId value is passed from the tag <netui:radioButtonOption> to the HTML tag <label>.

当你需要传递tagId值给一个HTML标签(或者其他没在<netui...>标签库里的标签)的时候,这个标签尤其有用。

    <netui:radioButtonOption tagId="radio1" value="value1"/>
    <label for="<netui:getNetuiTagName tagId="radio1"/>">Display Text 1</label>

If the tagId attribute in the tag is re-written, the <label> can access the re-written value through the tag <netui:getNetuiTagName>.

Attributes

idThe id attribute is deprecated, use the tagId attribute instead. The id attribute of the rendered HTML tag.
 
RequiredSupports runtime expression evaluationData bindable
NoNo

tagId

这个ID属性不被推荐,用tagId属性代替。

String value. Sets the id (or name) attribute of the rendered HTML tag. Note that the real id attribute rendered in the browser may be changed by the application container (for example, Portal containers may change the rendered id value to ensure the uniqueness of id's on the page). In this case, the real id rendered in the browser may be looked up through the JavaScript function getNetuiTagName( tagId, tag ).

注意,传给浏览器的真正的id属性可能被程序容器改变(例如,Portal容器可能改变传递的id值以保证id在页面中的唯一性)。真正的id可以通过javascript函数getNetuiTagName( tagId, tag )来查询。

For example, assume that some tag's tagId attribute is set to foo.

    <netui:textBox tagId="foo" />

Then the following JavaScript function will return the real id attribute rendered in the browser:

    getNetuiTagName( "foo", this )
这个函数将查找传给浏览器的真正的id属性。

To get a <netui:form> element and all of its children elements in JavaScript, use the same JavaScript function getNetuiTagName( tagId, tag ). For example, assume that there is a <netui:form> whose tagId attribute is set to bar.

可以使用这个函数,来得到<netui:form>元素和所有的孩子元素。

    <netui:form tagId="bar" >

Then the following JavaScript function will return the <netui:form> element and its children (packaged as an array).

    document[getNetuiTagName( "bar", this )]
这个函数将得到<netui:form> 元素和它所有的孩子元素(被包装成一个数组)。

To retreive the value entered into a <netui:textBox> within the <netui:form> tag, use the following JavaScript expression.

    document[getNetuiTagName("bar", this)][getNetuiTagName("foo", this)].value

The second parameter ensures that the JavaScript function begins its search within the correct Portlet scope. Pass the JavaScript keyword this as the second parameter. For detailed information on using the function getNetuiTagName( tagId, tag ) see Using JavaScript in Page Flow and Portal Applications.

 
RequiredSupports runtime expression evaluationData bindable
YesYesNo

Sample

    <netui:form action="processData">
        <netui:radioButtonGroup dataSource="{actionForm.selection}">
            <label for="<netui:getNetuiTagName tagId="radio1"/>">Display Text 1</label><netui:radioButtonOption tagId="radio1" value="value1"/><br>
            <label for="<netui:getNetuiTagName tagId="radio2"/>">Display Text 2</label><netui:radioButtonOption tagId="radio2" value="value2"/><br>
            <label for="<netui:getNetuiTagName tagId="radio3"/>">Display Text 3</label><netui:radioButtonOption tagId="radio3" value="value3"/><br>
        </netui:radioButtonGroup>    
        <netui:button value="Submit" />
    </netui:form>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值