Ajax Request On Dismissal Of Twitter Bootstrap Alerts November 09, 2024 Post a Comment I'm using the 'alert' functionality from Twitter Bootstrap to display user notifications, like so: Solution 1: In Bootstrap 3.0 you need to use namespaced event name:$('.alert').bind('closed.bs.alert', function () { var id = $(this).data('some_id'); $.get('closed.php?id='+id); }) CopySolution 2: According to the Bootstrap docs on alerts, I'd bind to the closed or close event, which are custom to Bootstrap.$(document).on('close', '.alert', function () { var id = $(this).data('some_id'); $.get('closed.php?id='+id); }); Copythere are two events exposed via the API:close - which is fired immediatelyclosed - fires after all animations have completed. I'd opt for close - this way you do it immediately and if they navigate / close before the animation completes, it will still be hidden.The data attribute is to be able to have the server side script differentiate between the alerts. The markup would be:<divclass="alert"data-some_id='foobar'> Close me! </div>Copy Share Post a Comment for "Ajax Request On Dismissal Of Twitter Bootstrap Alerts"
Post a Comment for "Ajax Request On Dismissal Of Twitter Bootstrap Alerts"