简体   繁体   中英

Listening for event in Dart via JQuery “on” with dart:js

I use dart call bootstrap modal window,and I want register a callback function ,but found the same problem other person mentioned before.

here is jQuery code:

$('#myModal').on('hidden.bs.modal',function (e) {....})

How can I write the same code in dart with dart:js , because package:js is deprecated; so I can't use callback function .

Thanks a lot !!!

This should work

import 'dart:js' as js;
...
void someCallback(e) {
  print('callback called, passed: $e');
}
...
js.context.callMethod(r'$', ['#myModal'])
    .callMethod('on', ['hidden.bs.modal', someCallBack]);

or

...
js.context.callMethod(r'$', ['#myModal'])
    .callMethod('on', ['hidden.bs.modal', (e) {
        print('callback called, passed: $e');
}]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM