Setting Custom HTML Attributes on Visualforce Components
我们在做成VF的时候,很多的时候需要用到Juqery的选择器来选去对象,有的时候,因为某些原因,我们需要对 <apex'inputText>等控件进行动态的id设定,但是因为Salesforce的ID不支持动态设定的原因,我们就需要用到自定义的html属性方法
它的语法结构是以 html-开头,所有用html- 写的属性,salesforce都会认为你是自定义的html属性,可以允许你编译通过,它编译完生成的实际的属性名是去掉 [ html-]关键字的
例如:
<apex:inputText html-data-id="row_{!s.rowindex}" value="{!valxx}" />
他生成的html以后,会变成
<input type="text" data-id="row_1" value="OK" />
我们就可以利用jquery的selector语法来动态选取对象了
salesforce的custom html attributes 支持下列组件
Pass-through attributes are supported by the following
Visualforce
components.
- <apex:column>
- <apex:commandButton>
- <apex:commandLink>
- <apex:component>
- <apex:dataTable>
- <apex:form>
- <apex:iframe>
- <apex:image>
- <apex:includeScript>
- <apex:input>
- <apex:inputCheckbox>
- <apex:inputField>
- <apex:inputHidden>
- <apex:inputSecret>
- <apex:inputText>
- <apex:inputTextarea>
- <apex:messages>
- <apex:outputField>
- <apex:outputLabel>
- <apex:outputLink>
- <apex:outputPanel>
- <apex:outputText>
- <apex:page>
- <apex:pageBlock>
- <apex:pageBlockButtons>
- <apex:pageBlockSection>
- <apex:pageBlockSectionItem>
- <apex:pageBlockTable>
- <apex:panelBar>
- <apex:panelBarItem>
- <apex:panelGrid>
- <apex:sectionHeader>
- <apex:selectCheckboxes>
- <apex:selectList>
- <apex:selectOption>
- <apex:selectOptions>
- <apex:selectRadio>
- <apex:stylesheet>
- <apex:tab>
- <apex:tabPanel>