Maybe I'm misunderstanding, but startPlayer is a method on your element's prototype. You shouldn't need to bind it to `this` in the 2nd example. `this` is already the instance of your element.
On Sun, Aug 2, 2015 at 2:37 PM Darin Hensley <[email protected]> wrote: > In polymer 1.0, I have a custom element. > > > startPlayer: function() { > console.log('yow'); > this.playAnimation('entry'); > this.show = { backButton: true}; > youtubePlayer = this.$$('google-youtube'); > //for replay > if (youtubePlayer.playbackstarted) { > youtubePlayer.play(); > } > }, > enableElement: function(e) { > document.body.style.overflow = "hidden"; > this.show = { video: true}; > setTimeout(this.startPlayer.bind(this), 0); > }, > > > > `setTimeout` correctly binds the `this` shadow scope and > `this.playAnimation('entry')` and the following functions are available in > `startPlayer`. > > But with: > > startPlayer: function() { > console.log('yow'); > this.playAnimation('entry'); > this.show = { backButton: true}; > youtubePlayer = this.$$('google-youtube'); > //for replay > if (youtubePlayer.playbackstarted) { > youtubePlayer.play(); > } > }, > enableElement: function(e) { > document.body.style.overflow = "hidden"; > this.show = { video: true}; > var bob = this.startPlayer.bind(this); > bob(); > }, > > > this `window` object `this` is binded instead of the shadow element scope. > This means the shadow element functions are not available as `this.foo` but > instead are only available as `this.videoPlayer.foo`. How can I bind `this` > of the shadow scope without using `setTimeout`? > > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/polymer-dev/f595b225-a8e6-4419-8a76-9d75d97759d4%40googlegroups.com > <https://groups.google.com/d/msgid/polymer-dev/f595b225-a8e6-4419-8a76-9d75d97759d4%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/CACGqRCDQUoc7849vvxkTA%3D0K_%2BuVvNh%2BMmQtuqtoUAYOBMfvMg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
