Saturday 31 August 2013

button click in polymer dart does not work; needs polymer-element

button click in polymer dart does not work; needs polymer-element

I am creating my first polymer application/example and a simple button
on-click is not working. The method is not called. I would like to use a
simple button without creating a new polymer-element (the commented code).
If I use the buttons in the polymer-element, they work just fine.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Button</title>
<link rel="stylesheet" href="button.css">
<script src="packages/polymer/boot.js"></script>
</head>
<body>
<h1>Button</h1>
<template id="tmpl" bind>
<button on-click="myMethod">Click me!</button><!! DOES NOT WORK!!! -->
</template>
<!--
<polymer-element name="my-element" extends="div">
<template>
<p>
<button on-click="myMethod">Show Message</button>
<button on-click="myMethod">Hide Message</button>
</p>
</template>
</polymer-element>
<my-element id="test"></my-element>-->
<script type="application/dart" src="button.dart"></script>
</body>
</html>
..
import 'dart:html';
import 'package:polymer/polymer.dart';
void main() {
query("#tmpl").model = new MyClass();
}
@CustomTag('my-element')
class MyClass extends PolymerElement with ObservableMixin{
@observable String name="testname";
void myMethod(var e, var detail, var target) {
print("button works");
}
}

No comments:

Post a Comment