Polymer.dart propertyChanged

123 views
Skip to first unread message

Moises Belchin

unread,
May 14, 2014, 5:55:33 AM5/14/14
to w...@dartlang.org
Hi all,

With polymer 0.9.5.+2 i'm using this pattern to detect changes on my properties.

import 'package:polymer/polymer.dart';
@CustomTag('select-ou')
class SelectOu extends PolymerElement {

  @published String value = "";
  @published int selected = 0;

  SelectOu.created() : super.created();

  void valueChanged(o, v) {
    print('valuechanged');
    print('Value: $value');
  }
}

That works really well running in Dartium however when i compile to js (release or debug mode) valueChanged() is never invoked.

I tried Observable in my class definition but it has no effect.

class SelectOu extends PolymerElement with Observable {
.....
}

Am i missing something?

Thanks and regards.

------------------------------------------------------------------------
Un Saludo.
Moisés Belchín.

montyr75

unread,
May 14, 2014, 12:24:32 PM5/14/14
to w...@dartlang.org
See what happens if you use a different property name, instead of "value". Make it "foo" or something.

Moises Belchin

unread,
May 19, 2014, 7:24:35 AM5/19/14
to w...@dartlang.org
I chaged "value" property name to "valor" but I get the same problem.

Imágenes integradas 1
Regards.

------------------------------------------------------------------------
Un Saludo.
Moisés Belchín.


2014-05-14 18:24 GMT+02:00 montyr75 <mont...@gmail.com>:
See what happens if you use a different property name, instead of "value". Make it "foo" or something.

--
You received this message because you are subscribed to the Google Groups "Dart Web Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web+uns...@dartlang.org.
Visit this group at http://groups.google.com/a/dartlang.org/group/web/.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/web/74d6e97f-e720-4c05-806b-a63af1b8b613%40dartlang.org.

John Messerly

unread,
May 19, 2014, 1:51:35 PM5/19/14
to w...@dartlang.org
What does HTML look like for SelectOu?

I'm going to guess it's something like:

<polymer-element name="select-ou" extends="select" ...>
...
</polymer-element>

To use extends="select", 2 things are important:

  • always write it in HTML like this : <select is="select-ou"> ...
  • extend SelectElement like this:
class SelectOu extends SelectElement with Polymer, Observable {
...


Hope this helps :)
- John




Moises Belchin

unread,
May 20, 2014, 4:04:00 AM5/20/14
to w...@dartlang.org
I don't extend SelectElement. This is the HTML:

<polymer-element name="select-ou">
  <template>
    <select class="form-control" selectedIndex="{{selectedIndex}}" value="{{value}}">
      <option> &lt; Seleccione... &gt; </option>
      <option value="{{x}}" template repeat="{{x in orderItems.keys}}">
        {{orderItems[x]}}
      </option>
    </select>
  </template>
  <script type="application/dart" src="ous.dart"></script>
</polymer-element>

Nothing rare, nothing magic.

Thanks for the comments.

Any other idea?

------------------------------------------------------------------------
Un Saludo.
Moisés Belchín.


Moises Belchin

unread,
May 20, 2014, 5:37:21 AM5/20/14
to w...@dartlang.org
This is amazing !!!!

I had my <select-ou> polymer element inside a library. It's very useful for better organization and for a simple import paths.
Instead of import '../../.../ous/ous.html'; you can make import 'package:my_lib/ous/ous.html';

If i move the <select-ou> element inside the web project folder, everything works perfectly, data-binding works and onPropertyChanged events are invoked. However having the <select-ou> element in a separate library, although this library is located in the same project, onPropertyChanged events are never invoked.

I think this breaks the encapsulation and reusable polymer concepts.

Any ideas to solve this problem?

Thanks in advance.


------------------------------------------------------------------------
Un Saludo.
Moisés Belchín.


Günter Zöchbauer

unread,
May 20, 2014, 6:20:01 AM5/20/14
to w...@dartlang.org
And as far as I know you still need to call
polymerCreated();

in the constructor when you extend a DOM element

Günter Zöchbauer

unread,
May 20, 2014, 6:21:55 AM5/20/14
to w...@dartlang.org

Moises Belchin

unread,
May 20, 2014, 7:18:21 AM5/20/14
to w...@dartlang.org
Günter, thanks one more time.
I have to wait for next stable releases.

------------------------------------------------------------------------
Un Saludo.
Moisés Belchín.


Reply all
Reply to author
Forward
0 new messages