uploadify 在 jquery 可拖动 div 中不起作用

发布于 2025-01-06 18:49:56 字数 2250 浏览 5 评论 0原文

我试图将 uploadify 上传视频按钮放在可拖动元素中。

我的上传视频部分videos/_new_video

<p>Upload your Video </p>
<div id="video_attachment"></div>

<%= content_for (:scripts) do%>
<script type="text/javascript">
  $(function() {
    <% session_key = Rails.application.config.session_options[:key] %>
    var uploadify_script_data = {};
    var csrf_token = $('meta[name=csrf-token]').attr('content');
    var csrf_param = $('meta[name=csrf-param]').attr('content');

    uploadify_script_data[csrf_param] = encodeURI(encodeURIComponent(csrf_token));
    uploadify_script_data['<%= session_key %>'] = '<%= cookies[session_key] %>';

    $('#video_attachment').uploadify({
      uploader  : '<%= asset_path("uploadify/uploadify.swf") %>',
      script    : '<%= videos_path %>',
      wmode     : 'transparent',
      cancelImg : '<%= asset_path("uploadify/cancel.png") %>',
      fileDataName    : 'attachment',
      scriptData : uploadify_script_data,
      auto      : true,
      buttonText : 'Browse',
      onAllComplete : function(event, data){
        alert("Success!  Please be patient while the video processes.");
      },
      onError: function(event, ID, fileObj, errorObj){
        alert("There was an error with the file you tried uploading.\n Please verify that it is the correct type.")
      }
    });
  });
</script>

application.js

//= require jquery
//= require jquery_ujs
//= require uploadify/jquery.uploadify.v2.1.4.min
//= require uploadify/swfobject

profile.js

$(document).ready( function(){

/* For edit_draggable */
    $("#edit-draggable").draggable();

$("#edit-draggable").hide();

});

在我的个人资料/节目中,uploadify将在可拖动div之外工作,如下所示:

<%= render "videos/new_video"%> 
<div id="edit-draggable" class="ui-widget-content ui-dialog">

    <%= render "edit"%>
</div>

但它不会在可拖动div内工作,如下所示:

<div id="edit-draggable" class="ui-widget-content ui-dialog">
    <%= render "videos/new_video"%>   
    <%= render "edit"%>
</div>

有人知道问题是什么吗?

预先感谢您的帮助!

I am trying to put a uploadify upload video button in a draggable element.

My upload video partial videos/_new_video

<p>Upload your Video </p>
<div id="video_attachment"></div>

<%= content_for (:scripts) do%>
<script type="text/javascript">
  $(function() {
    <% session_key = Rails.application.config.session_options[:key] %>
    var uploadify_script_data = {};
    var csrf_token = $('meta[name=csrf-token]').attr('content');
    var csrf_param = $('meta[name=csrf-param]').attr('content');

    uploadify_script_data[csrf_param] = encodeURI(encodeURIComponent(csrf_token));
    uploadify_script_data['<%= session_key %>'] = '<%= cookies[session_key] %>';

    $('#video_attachment').uploadify({
      uploader  : '<%= asset_path("uploadify/uploadify.swf") %>',
      script    : '<%= videos_path %>',
      wmode     : 'transparent',
      cancelImg : '<%= asset_path("uploadify/cancel.png") %>',
      fileDataName    : 'attachment',
      scriptData : uploadify_script_data,
      auto      : true,
      buttonText : 'Browse',
      onAllComplete : function(event, data){
        alert("Success!  Please be patient while the video processes.");
      },
      onError: function(event, ID, fileObj, errorObj){
        alert("There was an error with the file you tried uploading.\n Please verify that it is the correct type.")
      }
    });
  });
</script>

application.js

//= require jquery
//= require jquery_ujs
//= require uploadify/jquery.uploadify.v2.1.4.min
//= require uploadify/swfobject

profile.js

$(document).ready( function(){

/* For edit_draggable */
    $("#edit-draggable").draggable();

$("#edit-draggable").hide();

});

in my profile/show, uploadify will work outside the draggable div like this:

<%= render "videos/new_video"%> 
<div id="edit-draggable" class="ui-widget-content ui-dialog">

    <%= render "edit"%>
</div>

but it won't work inside the draggable div like this:

<div id="edit-draggable" class="ui-widget-content ui-dialog">
    <%= render "videos/new_video"%>   
    <%= render "edit"%>
</div>

Anyone know what the problem is?

Thanks in advance for your help!

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

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

发布评论

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

评论(2

奈何桥上唱咆哮 2025-01-13 18:49:56

这应该有效:

.draggable({ cursor: "move", cancel: '.uploadify'})

This should work:

.draggable({ cursor: "move", cancel: '.uploadify'})
左秋 2025-01-13 18:49:56

好吧,我已经弄清楚了,所以我要回答我自己的问题。

事实证明,没有拖动手柄的可拖动 div 会屏蔽 div 中的点击事件,因此 uploadify 按钮被可拖动控件阻止。

解决方案是添加一个拖动手柄,因此只能通过单击 div 的一部分来拖动 div。

Ok I've figured this out so I'm going to answer my own question.

Turns out that a draggable div with no drag handle will mask up the click events in the div, so the uploadify button was getting blocked by the draggable.

the solution was to add a drag handle, so the div is only draggable by clicking on part of the div.

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