I'm creating a new site using the Bootstrap Framework and have issues trying to automatically close a boot strap alert after n seconds.
The main page contains a modal login form. Once a user attempts to login, providing the entered details are incorrect, i display a alert on the main page containing an error (wrong password, Unknown username etc).
So the alert appears fine, but i cant automatically close it, code below if anyone is able to help, thanks.
PHP (returns error and displays alert)
<?php
// show potential errors / feedback (from login object)
if (isset($login)) {
if ($login->errors) {
foreach ($login->errors as $error) {
$AlertError = $error;
echo '<div class="alert alert-warning alert-dismissible" role="alert" id="loginerror">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>' . $AlertError . '</strong>
</div>';
}
}
}
I've tried calling a java script functions from the above PHP code to then close the alert with no luck
$("#loginerror").fadeTo(2000, 500).slideUp(500, function(){
$("#loginerror").alert('close');