解决方法
Backbone的事件处理基于
delegate
,委托只能用于泡沫的事件.问题是负载事件不起泡;从
HTML5 specification:
If the download was successful
Set theimg
element to the completely available state,update the presentation of the image appropriately,and fire a simple event namedload
at theimg
element.
而simple event不会泡泡:
Firing a simple event named e means that an event with the name e,which does not bubble (except where otherwise stated) […]
所以你必须用这样的方式用手挂钩一个处理程序:
render: function() { var self = this; this.$el.append(some_html_with_img_elements); this.$el.find('img').on('load',function() { self.img_loaded() }); return this; }
原文地址:https://www.jb51.cc/js/152647.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。