dart-js-interop

Passing Dart objects to js functions in js interop

余生长醉 提交于 2019-12-12 17:38:50
问题 I've been playing around a bit with the new js interop of dart. So far everything was very straight-forward. But one thing I'm not sure about is how to deal with js stuff like this: MathJax.Hub.Config({ showProcessingMessages: false, showMathMenu: false .. many other different options }); I can translate the MathJax.Hub.Config part: @JS('MathJax') external MathJaxClass get MathJax; class MathJaxClass { external HubClass get Hub; } @JS('MathJax.Hub') class HubClass { external void Config

How to embed a jquery ui widget into a polymer-dart webcomponent

房东的猫 提交于 2019-12-12 09:04:39
问题 I try to embed a jquery ui widget, f.e. a datepicker into a polymer-dart webcomponent. The Webcomponent is defined like that: <polymer-element name="my-datepicker"> <template> <div id="datepicker"></div> </template> <script type="application/dart" src="clickcounter.dart"></script> </polymer-element> The initialisation of this widget is done in JS like that <script> $(function() { $( "#datepicker" ).datepicker();}); </script> How can I initialize that widget in dart in my polymer.dart

Using jqrangeslider with dart js-interop does not work

旧时模样 提交于 2019-12-11 18:37:55
问题 I am trying to use the jqrangeslider ( http://ghusse.github.io/jQRangeSlider/index.html ) in my web_ui app and it is not working. In my application main root dart file I have: void main() { js.scoped((){ js.context.jQuery("#slider").bind("valuesChanged", new js.Callback.many((e, data) { fromRange = data.values.min; toRange = data.values.max; })); }); main root html file I have: <script src="jquery.min.js"></script> <script src="jquery-ui.custom.min.js"></script> <script src="jQRangeSlider-min

js-interop: Passing javascript object from dart

£可爱£侵袭症+ 提交于 2019-12-11 13:09:05
问题 I'm struggling to port javascript to dart.. My problem is how to create javascript object. original javascript code is function Beagle() { this.argv_ = null; this.io = null; }; Beagle.prototype.run = function() { this.io = this.argv_.io.push(); }; Now I have Beagle object. and it should be context['Beagle'] maybe? how can I create javascript obejct?? and with prototype ? 回答1: You are correct that Beagle should be available at context['Beagle'] . To create a new instance from Dart you need to

Dart JS Library, how to pass callback functions

≡放荡痞女 提交于 2019-12-11 05:09:33
问题 We are trying to wrap the D3 (v4) line generator class with a Dart wrapper with https://pub.dartlang.org/packages/js. We've followed https://github.com/google/chartjs.dart/ but are having problems passing through functions. Our wrapper looks like this: @JS('d3') library d3; import 'dart:js'; import "package:js/js.dart"; @JS('line') class Line { external Line(); external String call (List<List<num>> data); external Line x(Function func); external Line y(Function func); } We've currently

How to use javascript from Dart inside a polymer element

蹲街弑〆低调 提交于 2019-12-10 11:12:54
问题 I am trying to modify sample-google-maps to work inside a polymer element. On running following code I don't see anything except the title and there are no errors.Please advise how can I make this work. In longer run I want to define additional components using google-chart api and Polymer dart. Can someone point me to a worked out example. index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>DEMO</title>

Issue with chrome.runtime.onConnect when building chrome extension in dart

不打扰是莪最后的温柔 提交于 2019-12-10 10:17:47
问题 I have the following problem when running dart2js compiled version of my chrome extension: Uncaught TypeError: undefined is not a function when executing context['chrome']['runtime']['onConnect'].callMethod('addListener', [(port) { ... }]); I have created an example which possibly points to the cause: background.dart import 'dart:js'; void main() { print("main(): context['chrome']['runtime']['onConnect'] (${context['chrome']['runtime']['onConnect'].runtimeType}): ${context['chrome']['runtime'

Closure call with mismatched arguments: function 'call'

 ̄綄美尐妖づ 提交于 2019-12-08 13:11:20
问题 I'm using the (2.0)js-interop library in combination with the JS library ImageLoaded and I'm stuck the FunctionProxy class because the code below throw the foolowing error: Breaking on exception: Closure call with mismatched arguments: function 'call' js.FunctionProxy loaded = new js.FunctionProxy((){ print("called"); js.Proxy pckry = new js.Proxy(context.Packery, container, options); }); js.Proxy img = new js.Proxy(context.imagesLoaded, container, loaded); Wich is weird because my js

Dart onYouTubeIframeAPIReady

安稳与你 提交于 2019-12-08 07:52:37
问题 How can i create function onYouTubeIframeAPIReady from this example https://developers.google.com/youtube/iframe_api_reference#Getting_Started in Dart? The API will call this function when the page has finished downloading the JavaScript for the player API. 回答1: Thank you, Günter! It's working in in Chrome. <!DOCTYPE html> <html> <body> <div id="player"></div> <script type="application/dart" src="ytube_iframe.dart"></script> <!-- for this next line to work, your pubspec.yaml file must have a

Convert JS object into Dart classes

自古美人都是妖i 提交于 2019-12-08 04:58:44
问题 What is the best pattern to use to convert objects from Javascript to their Dart class counter parts? // car.dart import 'part.dart'; class Car { String paintColor; List<Part> parts; } // part.dart class Part { String name; String SKU; } // main.dart import 'dart:html'; import 'dart:js'; import 'car.dart'; void main() { var body = document.querySelector('body'); body.addEventListener('carSelect', loadCarHandler, false); } void loadCarHandler(event) { // this is the contents of a CustomEvent