【发布时间】:2012-01-07 16:20:41
【问题描述】:
给定 运行时 silverlight 当我点击上传按钮 然后什么都没有发生
适用于 html5 和 flash。我现在正在彻底测试,因为 IE 出现了 plupload flash 的错误(未设置容器,这让 IE 吓坏了。)为了确保没有更多的错误,我尝试将 silverlight 作为唯一的运行时进行测试,遗憾的是导致了这个无声错误。它在 FF、Mac 上的 chrome 或 Windows 上的 IE9 中都不起作用。
我正在使用 Backbone 和 coffeescript(Rails 3 应用程序)
这就是我在class window.Uploader extends Backbone.View 中构建plupload 的方式
.请记住,它使用 flash 和 html5 作为运行时:
initialize: (options) ->
@uploader = new plupload.Uploader({
runtimes : 'silverlight,flash', #'gears,html5,flash,silverlight,browserplus',
browse_button : 'pickfiles',
container: 'upload_container'
max_file_size : '5mb',
url : "/admin/upload",
flash_swf_url : '/publiclib/plupload.flash.swf',
silverlight_xap_url : '/publiclib/plupload.silverlight.xap',
filters : [ {title: "#{filter_title} ", extensions : "#{filter_extentions}"}]
multi_selection: that.multiple,
multipart: true,
multipart_params: {
"authenticity_token" : FORM_AUTH_TOKEN
},
file_data_name: 'photo'
})
###### THIS PRINTS SILVERLIGHT as runtime, in all browser I've tested for this Q
###### So it is used/detected, but not working
@uploader.bind 'Init', (up, params) ->
$('#filelist').html("<div>Current runtime: #{params.runtime} </div>")
@uploader.init()
@setupBindings()
setupBindings: ->
#instantiates the uploader
that = @
# shows the progress bar and kicks off uploading
@uploader.bind 'FilesAdded', (up, files) ->
_.each files, (file) ->
$('#filelist').append('<div id="' + file.id + '"><small>' + file.name + ' (' + plupload.formatSize(file.size) + ') </small><b></b>' + '<div class=" percent label notice" style="width:10%;"><span>Laster opp</span></div></div>')
that.uploader.start()
#binds progress to progress bar
@uploader.bind 'UploadProgress', (uploader, file) ->
# .. some upload code, not relevant to Q
这是我的 _form.html.erb(请原谅我不喜欢 haml)
<div id="upload_container" class="clearfix">
<div class='input'>
<div class='clearfix'>
<%=activity_image @activity%>
</div>
<%=link_to "Choose Picture", '#', :id => "pickfiles", :class => "btn small"%>
<div class='clearfix' id='filelist'>
</div>
</div>
</div>
根据评论中的要求生成 html...:
<fieldset>
<input id="activity_photo_id" name="activity[photo_id]" size="30" style="display:none;" type="text" />
<legend>choose picture for upload</legend>
<div id="upload_container" class="clearfix">
<div class='input'>
<div class='clearfix'>
<img src='/assets/default_photo.png' id='image_preview'>
</div>
<a href="#" class="btn small" id="pickfiles">Choose Picture</a>
<div class='clearfix' id='filelist'></div>
</div>
</div>
</fieldset>
当我点击“选择图片”时,什么也没有发生。
上传 1.5.1.1
【问题讨论】:
-
也许你可以包含生成的 HTML?
-
包括在内。你有silverlight plupload的工作实现吗?我怀疑 silverlight 没有绑定到 upload_container 或按钮,因为单击它时没有任何反应。如何找到silverlight监听的区域?
-
您的控件是否在 iframe 中? IE7/6 在 iframe 中都有问题,无论是 flash 还是 silverlight 插件。一旦我将它们从 iframe 中拉出并内联使用,就可以正常工作。
-
不在 iframe 中。我没有解决这个问题,我删除了silverlight。 html5和flash就够用了。
标签: ruby-on-rails silverlight coffeescript plupload