在 fancybox 内上传 - 不工作

发布于 2024-10-19 00:11:33 字数 191 浏览 1 评论 0原文

有人在 fancybox 中成功使用 uploadify 吗?如果我在普通页面上创建表单设置,则 uploadify 可以正常工作,但如果我采用完全相同的代码并将其放入 fancybox 中,则效果不佳。 uploadfield更改为uploadify,但是当在我的按钮上调用uploadifyUpload时,uploadify的js给出错误。有这方面的经验或想法吗?

Has anyone succesfully used uploadify inside fancybox? If I create a form setup on a normal page uploadify works perfectly, but if I take the exact same code and puts inside a fancybox it does not. The uploadfield is changed to uploadify, but when calling uploadifyUpload on my button the js of uploadify gives an error. Any experience or ideas on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

话少情深 2024-10-26 00:11:33

我知道这确实很旧,但是在我进行搜索后似乎没有一个好的答案,所以我想在这里添加一个:

解决方案是每次打开 fancybox 窗口时初始化 uploadify,方法是在onStart() 处理程序。

如果 uploadify 已经初始化(例如,之前已经打开 fancybox),则必须添加代码来重置 uploadify。您可以通过在 onStart() 处理程序中并在初始化 uploadify 之前添加代码来完成此操作,类似于:

$('#ID_FOR_FANCYBOX').fancybox({
  // other fancybox settings...
  'onStart': function() {

    // check if it has already been initialized
    if ($('#file_queue').hasClass("uploadifyQueue"))
    {
      // remove uploadify 
      $('#file_queue').removeClass('uploadifyQueue');
      $("#file_upload").unbind("uploadifySelect");
      swfobject.removeSWF('file_uploadUploader');

      // reset the html so we can initialize uploadify again
      $('#modal_upload .footer').html('<p><input type="file" id="file_upload" name="file_upload" /> or <a href="#" onclick="$.fancybox.close();return false;">cancel</a></p>');
    }

    // init uploadify here...

});

I know this is really old, but there doesn't seem to be a good answer anywhere after I did a search, so I wanted to add one here:

The solution is initialize uploadify each time the fancybox window is opened, by doing it in the onStart() handler.

You'll have to add code to reset uploadify if it had already been initialized (e.g. fancybox has already been opened before). You can do this by adding code within the onStart() handler and before initializing uploadify, similar to this:

$('#ID_FOR_FANCYBOX').fancybox({
  // other fancybox settings...
  'onStart': function() {

    // check if it has already been initialized
    if ($('#file_queue').hasClass("uploadifyQueue"))
    {
      // remove uploadify 
      $('#file_queue').removeClass('uploadifyQueue');
      $("#file_upload").unbind("uploadifySelect");
      swfobject.removeSWF('file_uploadUploader');

      // reset the html so we can initialize uploadify again
      $('#modal_upload .footer').html('<p><input type="file" id="file_upload" name="file_upload" /> or <a href="#" onclick="$.fancybox.close();return false;">cancel</a></p>');
    }

    // init uploadify here...

});
故事未完 2024-10-26 00:11:33

抱歉我回复晚了,没有收到您的评论通知 - 代码现在已更改为使用另一个 jQuery 上传脚本,来自 lagoscript.org,我还对其进行了一些修改以更好地满足我的需求。这样我还可以避免使用 Flash,这可能会成为我正在从事的项目中的一个问题。

Sorry for my late response, wasnt notifed about your comment - the code is now changed to use another jQuery upload script, one from lagoscript.org, which I also modified a bit to better fit my needs. This way I also avoid the use of Flash which could become an issue in the project I am working on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文