How to call the default behavior's method in Polymer 1.0? -


in polymer 1.0 have behavior script defines properties , methods:

<script> databehavior = {   properties: {     data: {       type: array,       value: null,       observer: 'datachanged'     }   },   datachanged: function(newvalue, oldvalue) {     console.log('default stuff');   } }; </script> 

and components uses behavior:

<dom-module id="my-module">   <template>   </template>   <script>   polymer({     is: "my-module",     behaviors: [databehavior],     datachanged: function(newvalue, oldvalue) {       // how call datachanged method databehavior?       // this.super.datachanged(); <- don't works!       console.log('custom stuff');     }   });   </script> </dom-module> 

when change data property method executed my-module, make "custom stuff". if remove datachanged method in my-module execute "default stuff".

how can execute both default behavior's method , component's method?

if possible don't want copy code "databehavior.datachanged" "my-module.datachanged". i'd call behavior's method inside component's method; can use "super" refer behavior script?

thank answers!

you call databehavior.datachanged.call(this, newvalue, oldvalue):

<dom-module id="my-module">   <template>   </template>   <script>   polymer({     is: "my-module",     behaviors: [databehavior],     datachanged: function(newvalue, oldvalue) {       databehavior.datachanged.call(this, newvalue, oldvalue)     }   });   </script> </dom-module> 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -