javascript - Meteor + Bootstrap - Alert closed.bs.alert does not trigger -


i'm using meteor , bootstrap, nemo64:bootstrap package. in custom.bootstrap.json have "alerts" , "alert" on.

i'm trying capture closed.bs.alert event in template events. reason, won't capture.

template.alert.events({     'closed.bs.alert .alert': function () {         console.log('closed'); // not trigger     } }); 

oddly, close.bs.alert work:

template.alert.events({     'close.bs.alert .alert': function () {         console.log('closed'); // triggers     } }); 

also, if add event via jquery, can capture closed.bs.alert:

$('.alert').on('closed.bs.alert', function () {     console.log('closed'); // triggers });  

so, know have events formatted correctly , know closed.bs.alert event triggering... reason can't catch template.alert.events.

any ideas?

i dove in bootstrap code , found triggered event: alert.js, line 50

first, technique got work:

templates.alert.onrendered({     $('.alert').on('closed.bs.alert', function (e) {         console.log('closed'); // triggers =d     }); }); 

i think problem lies in fact bootstrap detaches alert before triggering event, things $(document).on('closed.bs.alert', '.alert') can't work. don't know 100% sure, suspect meteor's template.my_template.events() trigger using similar method well.

normally work:

$(function () {     $('.alert').on('closed.bs.alert', function () {         console.log('closed'); // doesn't trigger     }); }); 

however, meteor throws wrench in plan because i'm loading alerts data, aren't there when trigger.

however, putting jquery-style on() in template.my_template.onrender() seems trick.

also, bootstrap doesn't throw event unless alert has "fade" class. can assign fade class without including "transition" module. if leave off, won't effect, event can fire regardless.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -