Gene
Gene

Reputation: 616

How to call a Dart program from Javascript?

Given that Dart will need to inter-operate with other javascript frameworks. In the client-web environment what are the current or intended best-practices to communicate with a Dart program from javascript?

Upvotes: 4

Views: 428

Answers (2)

greensuisse
greensuisse

Reputation: 1827

Sample code:

import 'package:js/js.dart' as js;

js.context.jQuery();
var context = js.context;  
var param = js.map({ 'modal': true, "width":1000, "height":600});
js.context.jQuery("#dialog").dialog(param); 

in html

<script src="packages/browser/interop.js"></script>

The above code open a div as dialog using jQuery.

Upvotes: 1

Lars Tackmann
Lars Tackmann

Reputation: 20865

Currently you need to use window.postMessage to communicate with Dart however a interorp layer is planned and should arrive in dart2js any day now (although I believe that its initial incarnation will focus more Dart->JavaScript than JavaScript->Dart).

Upvotes: 3

Related Questions