2012-02-16 70 views
0

我試圖在可拖動元素中放置uploadify上傳視頻按鈕。uploadify在jquery draggable div中不起作用

我上傳的視頻部分的視頻/ _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> 

任何人都知道問題是什麼?

在此先感謝您的幫助!

回答

0

好的我已經想通了,所以我要回答我自己的問題。

原來,一個沒有拖動柄的可拖動div將掩蓋div中的點擊事件,所以uploadify按鈕被拖動塊阻塞。

解決方案是添加一個拖動手柄,因此div只能通過單擊部分div來拖動。

2

這應該工作:

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