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.

有帮助吗?

解决方案

Aside the typo in ['.content"'] (instead of ['.content']) it looks good to me if you are using import dart:js; and not 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!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top