Skip to content

Instantly share code, notes, and snippets.

@marcioj
Created August 11, 2013 22:04
Show Gist options
  • Save marcioj/6207084 to your computer and use it in GitHub Desktop.
Save marcioj/6207084 to your computer and use it in GitHub Desktop.
Displays a video with data binding using ember.js http://jsfiddle.net/marciojunior/KZxgp/.
<script type="text/x-handlebars" data-template-name="video">
{{view view.embedView}}
</script>
<script type="text/x-handlebars" data-template-name="embed">
<object width="640" height="390">
<param name="movie" {{bindAttr src="view.src"}} ></param>
<param name="allowScriptAccess" value="always"></param>
<param name="playerapiid" value="main"></param>
<embed {{bindAttr src="view.src"}} type="application/x-shockwave-flash" allowscriptaccess="always" width="640" height="390"></embed>
</object>
</script>
App.VideoView = Ember.View.extend({
templateName: 'video',
embedView: Ember.View.extend({
src: null,
templateName: 'embed',
srcBinding: 'parentView.src',
viewName: 'embed'
}),
src: null,
srcChanged: function() {
this.get('embed').rerender();
}.observes('src')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment