views:

44

answers:

0

Hello,

Simply my problem is my ajax scripts do not work if I click the link via Jquery .trigger instead of human click.

If you want the whole story, please continue reading. I have used Jquery trigger function in my project. Let me explain first what does this do? I integrated Facebook login api to my project's user management system. If a user logs in to website with his Facebook account, page checks whether he registered to my website before or not. If he is not registered before, a register modalbox is appearing on page with username and email fetched from Facebook. To open the modalbox I used Jquery's trigger function. If $me isset on page and e-mail address is not registered on system, the login button is triggered. Modalbox appears with no problem but problems beginning just after this. My javascript functions does not work properly. For example the submit button of registration form's submit button which is also a ajax form returns a javascript alert window with "success" message.

Actual login link: (If user logged in removes id and turns into logout link)

<li>
<span>
<a<?php if (isUserLoggedIn()){echo ' href="users/logout.php"' ;} 
else {echo ' id="login_link" href="includes/_modal.login.inc.php"';}?>>
<?php if (isUserLoggedIn()){    echo "Logout" ;}else{   echo "Login" ;}?></a></span>
</li>

Here is my HTML for register form:

<form id="register" action="javascript:alert('success!');">
<input type="hidden" name="action" value="user_register">
<input type="hidden" name="module" value="login">
<label>Username</label><input type="text" name="username" value="<?php if($me) {echo $username;}?>"><br />
<label>Password</label><input type="password" name="password"><br />
<label>Password (again)</label><input type="password" name="passwordc"><br />
<label>E-mail</label><input type="text" name="email" value="<?php if($me) {echo $me['email'];}?>"><br />
<label>&nbsp;</label><input value="Register" name="Register" id="submit_register" class="big" type="submit" />
<img align="absmiddle" src="images/spinner.gif">&nbsp;Working...
</div>
</form>

And my usage of trigger:

<?php if($me && empty($userMail)):?>
<script>
jQuery(document).ready(function() {
$("#login_link").trigger('click');
});
</script>
<?php endif;?>

My login modalbox appears when #login_link tag clicked.

Thanks,