简体   繁体   中英

Calling Jquery function in DART lang

I'm trying to convert the following jquery script in DART :

<script>
    (function($){
        $(window).load(function(){
            $(".content").mCustomScrollbar();
        });
    })(jQuery);
</script>

I've wrote the following code in DART :

  js.context
  .callMethod(r'$', ['.content"'])
  .callMethod('mCustomScrollbar');

But it's not working. Any help is appreciated.

除了['.content"']的拼写错误(而不是['.content'] ),如果您使用import dart:js;并且不import 'package:js/js.dart'对我来说它看起来不错。

The wrong quote is just a copy/past error. The code in DART is correct when using import dart.js

In fact , to use the jQuery custom content scroller plugin http://manos.malihu.gr/jquery-custom-content-scroller/ , I have to include the following script :

<!-- Google CDN jQuery with fallback to local -->
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/minified/jquery-1.11.0.min.js"%3E%3C/script%3E'))</script>

I forgot to do it. so everything is Ok right now. Thank You guys!

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