【问题标题】:plupload with silverlight not working - ok with html5 and flashplupload 与 silverlight 不工作 - 好的 html5 和 flash
【发布时间】: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


【解决方案1】:

根据您的样式,Plupload 结构可能会在您的容器中丢失 (#upload_container)。尝试将 browse_button 元素包装到它自己的容器中,在屏幕上具有严格的位置。

可能是 Plupload 和 Backbone/CoffeeScript 之间的一些冲突,因为它作为独立的东西在这里工作,刚刚测试过。您可以在某处在线展示您的使用案例吗?

【讨论】:

  • 我刚刚发现错误仍然存​​在于 IE8 中。我会试试你的建议。
  • my @uploader.bind 'Init' 在加载页面时未在 IE8 中触发。在 IE8 中,我没有看到“当前运行时是..”
  • 我可以进一步帮助你,但我真的需要看看你的情况。再次原因,作为独立案例,它可以在此处的任何 IE 中使用。顺便问一下,Plupload 网站 (plupload.com/example_all_runtimes.php) 中的示例在 IE8 中是否适合您?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多