uploadify 在 jquery 可拖动 div 中不起作用
我试图将 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该有效:
This should work:
好吧,我已经弄清楚了,所以我要回答我自己的问题。
事实证明,没有拖动手柄的可拖动 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.