我有以下要求:
因此,我需要点击自定义标记生成的href链接,该标记会在呈现页面时生成href链接。
<abs:resourceLink id="printQuoteResourceLink" action="downloadSaveQuote"
label="#{msg.quotePrint}"/>
这会在加载页面时呈现href:
<a id="pb42583:pageform:printQuoteResourceLink"
name="pb42583:pageform:printQuoteResourceLink"
href="/broker/broker/Home/Buy/ProductSimple?portal%3AwindowState=normal&navigationalstate=JBPNS_rO0ABXceAAlleGVjdXRpb24AAAABAARlMXM0AAdfX0VPRl9f&portal%3AcomponentId=8878e340-f05e-47d3-bdcb-42d29a6c62b3&portal%3AcacheLevel=PAGE&resourcestate=JBPNS_rO0ABXdyAA5zcHJpbmdSZXNvdXJjZQAAAAEAAAAMc3ByaW5nQWN0aW9uAAAAAQARZG93bmxvYWRTYXZlUXVvdGUABGRhdGUAAAABAA0xNDUxNTYzNTI2ODc0AAlleGVjdXRpb24AAAABAARlMXM0AAdfX0VPRl9f&portal%3Atype=resource&portal%3AportletMode=view">Print quote
</a><script type="text/javascript">
我目前的代码:
<h:panelGroup id="panelPrintQuote">
<div class="bordered button">
<h:commandButton class="bordered button" style="width: 154px;float:left;margin-left:640px !important; font-size:1em !important;
Padding: 0px 7px 0px 0px;" id="printQuoteCommandButton" value="#{msg.quotePrint}" action="generateSaveQuote" >
<a4j:ajax render="panelPrintQuoteResource"/>
</h:commandButton>
<!-- <abs:resourceLink id="printQuote" action="downloadSaveQuote"
label="#{msg.quotePrint}" image="/resources/images/transparent_image.png"/> -->
</div>
</h:panelGroup>
<h:panelGroup id="panelPrintQuoteResource" rendered="#{bnl_WebPageConfirmation.documentAvailable}">
<abs:resourceLink id="printQuoteResourceLink" action="downloadSaveQuote"
label="#{msg.quotePrint}" style="display:none;" image="/resources/images/transparent_image.png"/>
<h:outputScript>
//<![CDATA[
window.onload= $('a[href$="printQuoteResourceLink"]').click(function(){});
//]]>
</h:outputScript>
答案 0 :(得分:0)
您可以使用trigger('click')
,因为元素已使用.click()
var a = $('a[href$="printQuoteResourceLink"]'); // cache the element for better performance
a.click(function(){
a.trigger('click');
});
但你也使用
$('a[href$="printQuoteResourceLink"]')[0].click();
[0]
将获取具有.click()
函数
另一种方法是使用.get(0)
来获取DOM对象,与[0]
$('a[href$="printQuoteResourceLink"]').get(0).click();