Reputation: 27058
<?php if(isset($_SESSION['cnt'])&&($_SESSION['cnt'] == 5) ){
$_SESSION['cnt'] = 0;
?>
<script>
//$("#fb_login").trigger('click');
//$('#fb_login').click();
$("#fb_login").click(function(){
$("#fb_login").colorbox({width:"300px", height:"200px", inline:true, href:"#loginask_iframe"});
});
</script>
<?php } ?>
<a href="#" id="fb_login"></a>
<div style='display:none' class="loginask_iframe_container">
<div id="loginask_iframe">
test
</div>
</div>
i can't get the click function to trigger when the $_SESSION['cnt'] == 5
.
any ideas what i am doing wrong? thanks
Upvotes: 0
Views: 699
Reputation: 49238
<script>
function triggerLoginColorBox() {
$("#fb_login").colorbox({
width: "300px",
height: "200px",
inline: true,
href: "#loginask_iframe"
});
}
$("#fb_login").click(function(){triggerLoginColorBox();});
<?php
if (isset($_SESSION['cnt']) && ($_SESSION['cnt'] == 5) ){
$_SESSION['cnt'] = 0;
echo "triggerLoginColorBox();";
}
?>
</script>
Upvotes: 1
Reputation: 4283
This may be a case of the click function being defined before the anchor is created. Try wrapping the click binding in $(document).ready( ...
Upvotes: 1
Reputation: 14932
<script type="text/javascript">
// Here you define the click.
$("#fb_login").click(function(){
$("#fb_login").colorbox({width:"300px", height:"200px", inline:true, href:"#loginask_iframe"});
});
// Here you call the click.
$("#fb_login").click();
</script>
Upvotes: 1
Reputation: 7703
Is this what you're looking for?
$("#fb_login").trigger('click');
Upvotes: 2