I want to Access a method in a polymer instance from another element.

52 views
Skip to first unread message

Chrispinus Onyancha

unread,
Nov 4, 2015, 1:26:43 AM11/4/15
to Polymer
http://plnkr.co/edit/wkFOzB1Dyjd16SaMJV6S?p=preview   Please help me understand what could be the issue with this? 

I want to call the method add from the parent element.  

<dom-module id="my-one">
  <template>
    <my-element></my-element>
  </template>
</dom-module>
<script>

Polymer({
      is: 'my-one',
      properties: {
        
      },
      ready:function(){
         var element = document.querySelector('my-element');
         console.log(element.add(2,7));

      }
    });
   

</script>


And the my-element looks like this.


<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="all-elements.html">

<script>
var cast = window.cast || {};
(function () {
    'use strict';
    var Element = Polymer({
      is: 'my-element',
      properties: {
        
      },
      add:function(one, two){
        return one+two;
      }
    });
    Elemet.ValueX ={name: "Chris"};
    cast.Element = Element;
})();

</script>


Eric Bidelman

unread,
Nov 4, 2015, 2:13:29 PM11/4/15
to Chrispinus Onyancha, Polymer
document.querySelector will look for elements in the main document. You want to look for my-element inside of your element's shadow dom.

Polymer.dom(this.root).querySelector('my-element') or better yet, put an id on my-element and use node finding.


Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/d731e875-f2f5-4270-b473-05591787c5e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chrispinus Onyancha

unread,
Nov 5, 2015, 12:10:45 AM11/5/15
to Eric Bidelman, Polymer, davidmax...@gmail.com
Thanks So much this worked out for me. 
Thanks once More.

Another issue i have is uploading an image to Google App Engine  BlobStore using polymer iron-ajax element.  It need a Cross Domain request Access which is to be added by Google. Is there any way around this? 






Regards, 

Onyancha Chrispinus
Developer




Chrispinus Onyancha

unread,
Nov 5, 2015, 3:39:38 AM11/5/15
to Eric Bidelman, Polymer, David Waterman
I don't know if every body finds this site down https://www.polymer-project.org like i do. I have tried to access it for days now.






Regards, 

Onyancha Chrispinus
Developer





Eric Bidelman

unread,
Nov 5, 2015, 11:18:54 AM11/5/15
to Chrispinus Onyancha, Polymer, David Waterman

It's working new for me. We haven't had any reports. Maybe something to do with your setup?

Reply all
Reply to author
Forward
0 new messages