V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
sohu022
V2EX  ›  JavaScript

WebUploader 有没有办法用代码触发点击上传

  •  
  •   sohu022 · 2016-10-20 15:25:32 +08:00 · 5175 次点击
    这是一个创建于 2750 天前的主题,其中的信息可能已经有所发展或是发生改变。
    RT , 试了一下发现不能触发,大家有没有什么办法?
    6 条回复    2017-10-26 17:33:42 +08:00
    sohu022
        2
    sohu022  
    OP
       2016-10-20 15:50:04 +08:00
    @airycanon 我意思是触发点击按钮, 出现文件选择对话框 类似这样 http://jsfiddle.net/ebSS2/
    sohu022
        3
    sohu022  
    OP
       2016-10-20 15:59:37 +08:00
    @airycanon 应该没办法用代码触发。
    for example if you(the script) programmatically click the button in an ajax callback nothing will happen, but if you put the same line of code in an event handler that was raised by the user, it will work.
    airycanon
        4
    airycanon  
       2016-10-20 16:02:43 +08:00
    http://fex.baidu.com/webuploader/doc/index.html#WebUploader_Uploader_options
    这里写的很清楚,参数 pick 指定选择文件的按钮,请仔细阅读文档。
    airycanon
        5
    airycanon  
       2016-10-20 16:07:39 +08:00   ❤️ 1
    @sohu022 我才明白你的意思,没错,按钮的触发,只能由用户发起。
    hurrak
        6
    hurrak  
       2017-10-26 17:33:42 +08:00
    $('.webuploader-element-invisible').trigger('click');
    webuploader-element-invisible 是 div#picker 里面创建的 input[type=file] ,选择文件后会触发 webuploader 的后续事件。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2331 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 03:25 · PVG 11:25 · LAX 20:25 · JFK 23:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.