我使用JWPlayer在我的网站上显示视频,JWPlayer使用javascript创建查看器.
我的隐藏视图更改显示后,我必须运行JWPlayer脚本.
jwplayer('video_space').setup({
'flashplayer': 'player.swf',
'file': 'http://content.longtailvideo.com/videos/flvplayer.flv',
'controlbar': 'bottom',
'width': '470',
'height': '320'
});
Run Code Online (Sandbox Code Playgroud)
我将我的视图与控制器上的值绑定
<script type="text/x-handlebars" >
{{#view Food.previewView }}
Video session
<div {{bindAttr class="showPreview"}}>
<div id='video_space'>Video Loading...</div>
</div>
{{#view SC.Button target="Food.appController" action="show"}}
show
{{/view}}
{{/view}}
</script>
Run Code Online (Sandbox Code Playgroud)
我的javascript为所有控制器和视图
Food = Ember.Application.create();
Food.appController = Ember.Object.create({
showVideo: false,
show: function(){
Food.previewView.set('showVideo', true);
}
});
Food.previewView = Ember.View.extend({
showVideoBinding: 'Food.appController.showVideo',
showPreview: function() {
return this.get('showVideo') ? "show" : "hide";
}.property('showVideo')
});
Run Code Online (Sandbox Code Playgroud)
如果我在更改"showVideo"变量时运行JWPlayer脚本,视频将会出错,因为$('#video_space')仍然是隐藏的.
Emberjs有一些委托方法,如"afterViewChange"或"viewDidChange"?
小智 6
重写Ember.View.didInsertElement函数并将自定义项放在那里.
http://docs.emberjs.com/#doc=Ember.View&method=didInsertElement&src=false
| 归档时间: |
|
| 查看次数: |
4877 次 |
| 最近记录: |