我有以下coffeescript,除了这样的事实,即当图像需要一段时间加载它运行之前运行图像,然后没有所需的效果:
@H_404_2@ready = ->
jQuery ->
$('.Box').find('img').each ->
imgClass = if @width / @height > 1 then 'wide' else 'tall'
$(this).addClass imgClass
return
return
$(document).ready(ready)
$(document).on('page:load',ready)
如何在加载整个窗口后才能运行我的功能?
到目前为止我的最佳尝试看起来像
@H_404_2@window.onload = -> $('.Box').find('img').each -> imgClass = if @width / @height > 1 then 'wide' else 'tall' $(this).addClass imgClass return return但它不起作用.我也尝试了其他几种可能性,但我无法弄清楚什么是错的.
我的问题与this one不同,因为我不想等到所有coffeescripts都已完成加载,我想等到我的网页中的所有图像都已加载.