I am attempting to click a button when the onClose event occurs for fancybox.
I am thinking that I just have a syntax issue, but I am not completely sure. Here is my code. :
<script type="text/javascript">
var $_returnvalue = false;
$(document).ready(function () {
$(".stopNumberLnkItem").fancybox({
'width': '85%',
'height': '85%',
'autoScale': false,
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'speedIn': 400,
'speedOut': 400,
'type': 'iframe',
'showCloseButton': true,
'onClosed': function () {
if ($_returnvalue = 'Y') {
$('#Chkbxaddto').attr('checked', 'checked');
}
$(".gridStopSelectorListLnkItem").trigger('click');
}
});
});
</script>
Here is my linkbutton that I am attempting to click via the trigger(‘click’) above. :
<asp:LinkButton runat="Server" ID="RefreshGridStopListButton" Text="Refresh Grid Stop List" CssClass="gridStopSelectorListLnkItem"
OnClick="RefreshGridStopListButton_Click" Font-Size="smaller" Visible="true"/>
I have been trying different selectors and different ways of performing the click but to no avail. I have stepped through with IE developer tools but it does not seem to be clicking that button. Any thoughts on this one would be greatly appreciated.
Thanks.
depends how that linkbutton is rendered in the HTML. If it’s a
<button>or I think also a<input type='button'>then you could just do$(".gridStopSelectorListLnkItem").click()but if it’s a<a>not sure if click() applies to that (but you can try)