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.
For more options, visit https://groups.google.com/d/optout.