我正在尝试在我拥有的表单上实现 SWFUpload。但是,它没有识别占位符。我的代码在下面,有人可以帮忙吗?如果有帮助,我正在使用 jQuery。
标题:
<script type="text/javascript" src="{{ MEDIA_URL }}/js/SWFUpload-2.5.0/swfupload/swfupload.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}/js/SWFUpload-2.5.0/swfupload/swfupload.cookies.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}/js/foo.js"></script>
<script type="text/javascript">
$(swfupload("{% url swfupload %}","{{ MEDIA_URL }}/js/SWFUpload-2.5.0/swfupload/swfupload.swf"));
</script>
身体:
<div id="upload_btn"></div>
Javascript(foo.js):
swfupload = function(upload_url, flash_url) {
var swfupload_real = new SWFUpload({
debug: false,
upload_url: upload_url,
flash_url: flash_url,
button_placeholder_id: "upload_btn",
button_width: "40",
button_height: "16",
button_cursor: SWFUpload.CURSOR.HAND,
button_text: "Click",
file_size_limit: "20 MB",
file_dialog_complete_handler: function() { this.startUpload(); },
upload_complete_handler: function() { this.startUpload(); },
});
};
编辑:我尝试查看 SWFUpload.js 的源代码,发现在它试图找到元素的时候,它会这样做:
targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
我试着看看发生了什么,令人难以置信的是,在返回对象的document.GetElementByID
同时返回 null $('#'+this.settings.button_placeholder_id)
!我宁愿不修改库以使用另一个依赖项。有谁知道这可能是为什么?