Dave
Dave

Reputation: 33

How to call the functions of an other element contained inside template (ShadowDOM)?

The question is simple (I hope so). Is there a way to call the function myFunctA of my-elementA from my-elementB? Or any solution that works similarly to how public functions work in Java or C?

<polymer-element name="my-elementA">  
 <template>  
 ...  
 </template>

 <script>
 Polymer({

   myFunctA : function()
   {
   ...
   }

 });
</script>
</polymer-element>

<polymer-element name="my-elementB">  
 <template>
   <my-elementA></my-elementA>  
   ...  
 </template>

 <script>
 Polymer({

   myFunctB : function()
   {
   //call myFunctA()
   }

 });
</script>
</polymer-element>

Upvotes: 3

Views: 6133

Answers (1)

jimi dough10
jimi dough10

Reputation: 2016

<polymer-element name="my-elementB">  
 <template>
   <my-elementA id="element"></my-elementA>  
   ...  
 </template>

 <script>
  Polymer({

   myFunctB : function()
   {
     this.$.element.myFunctA();
   }

  });
</script>
</polymer-element>

Upvotes: 8

Related Questions