如何在加载模型后激发jquery效果
我开始使用Emberjs:) 我正在尝试用fadein jquery效果显示模型中的图片如何在加载模型后激发jquery效果,jquery,ember.js,Jquery,Ember.js,我开始使用Emberjs:) 我正在尝试用fadein jquery效果显示模型中的图片 $('.ember-view img').load( -> $(this).fadeIn(10000).show() ).each( -> $(this).load() if(this.complete) ) 我尝试了不同的方法来找到触发此事件的好位置,但未能找到创建触发此事件的方法的好位置 我有这条路线 MyApp.SquaresRoute = Ember.Route.extend
$('.ember-view img').load( ->
$(this).fadeIn(10000).show()
).each( ->
$(this).load() if(this.complete)
)
我尝试了不同的方法来找到触发此事件的好位置,但未能找到创建触发此事件的方法的好位置
我有这条路线
MyApp.SquaresRoute = Ember.Route.extend(
setupController: (controller) ->
controller.set('model', @store.find('sqimage'))
我还有2个控制器(数组和对象)
以及渲染对象的模板
{{#each controller}}
<img {{bind-attr src="url_thumbnail"}} {{bind-attr style="style"}} />
{{/each}}
{{#每个控制器}
{{/每个}}
我试图在视图文件中放置didInsertElement,但它不起作用
我应该使用观察员吗?我应该把它放在哪里
非常感谢你的回答 我会尝试为您的每个收藏项目使用单独的视图。代码应该如下所示: 您的系列车把模板:
{{#each item in controller}}
{{view App.ItemView context=item}}
{{/each}}
<img {{bind-attr src="url_thumbnail"}} {{bind-attr style="style"}} />
App.YourView = Ember.View.extend({
// these are two different styles to use the 'didInsertElement' hook. Choose the one you prefer
didInsertElement : function(){
this.$().find('img').fadeIn(10000);
},
yourEffectFunction : function(){
this.$().find('img').fadeIn(10000);
}.on("didInsertElement")
});
项目视图的把手模板:
{{#each item in controller}}
{{view App.ItemView context=item}}
{{/each}}
<img {{bind-attr src="url_thumbnail"}} {{bind-attr style="style"}} />
App.YourView = Ember.View.extend({
// these are two different styles to use the 'didInsertElement' hook. Choose the one you prefer
didInsertElement : function(){
this.$().find('img').fadeIn(10000);
},
yourEffectFunction : function(){
this.$().find('img').fadeIn(10000);
}.on("didInsertElement")
});
请注意:我真的不明白jquery代码应该做什么。因此,只需将视图中的逻辑替换为所需的代码。只需进行编辑,我们需要针对img元素,而不是视图容器,因此我认为我们应该编辑您的帖子,因为它可以正常工作。:-)将答案标记为已接受,作为其他用户的指南plz。