Reputation: 63
When I click the save button on the first time, the alert shows up fine. But every time after that, the alert doesn't show up unless I do a hard refresh.
Here is the JSFiddle: JSFiddle
$("#success-alert").hide();
$("#saveChange").click(function showAlert() {
$("#success-alert").alert();
$("#success-alert").fadeTo(2000, 500).slideUp(500, function() {
$("#success-alert").alert('close');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.1/js/bootstrap.min.js"></script>
<div class="product-options">
<button id="saveChange" href="javascript:;" class="btn btn-mini">Save</button>
</div>
<div class="alert alert-success" id="success-alert">
<button type="button" class="close" data-dismiss="alert">x</button>
<strong>Success! </strong>
Your changes has saved.
</div>
Upvotes: 1
Views: 879
Reputation: 5190
the line
$("#success-alert").alert('close');
destroys your alert so you cannot open it again.
remove that line and your alert will show each time
Upvotes: 5