2012-01-10 90 views
0

我想通過jquery ui模式上傳圖片..通過jquery ui模式上傳圖片

有可能嗎?我有關於如何從模態值問題..

我一直在尋找通過網絡,但目前還沒有明確的答案..

做任何人有任何想法?

這是我的模式窗體的JavaScript代碼:

$("#dialog").dialog({ 
       modal: true, 
       resizable: false, 
       width: 400, 
       position: "center", 
       buttons: { 
        "Upload": function() { 


                  var pos= $("#pos input:radio:checked").val(); 
                  // i still don't know how to get the value for the image uploaded 

                  $(this).dialog("close"); 

              }, 
        "Cancel": function() { $(this).dialog("close"); } 
            } 
      }); 
       }); 

這是我的模式形式:

<div id='dialog' title='ADD IMAGE' class='ui-dialog-content ui-widget-content'> 
     <form id='myform' method='POST' enctype='multipart/form-data'> 
     <fieldset> 
     <div id='pos'> 
     <p class='applyimage'>Where do you want to apply a background image?</p> 
     <p class='applyimage'><input type='radio' class='position' name='position' id='header' value='header' checked='checked'/>&nbsp;<label for='header'>Header</label> 
     <input type='radio' class='position' name='position' id='body' value='body'/>&nbsp;<label for='body'>Body</label> 
     <input type='radio' class='position' name='position' id='footer' value='footer'/>&nbsp;<label for='footer'>Footer</label></p> 
     <p class='applyimage'><input type='file' name='data[Image][fileName]' id='imgup'/></p> 
     </div> 
     </fieldset> 
     </form> 
     </div> 

回答

0

我建議你不要使用「按鈕」參數, 而是在您的表單上創建「上傳」按鈕。

如果你什麼都不做,它會加載你的表單被設置爲的行爲。


如果你真的想使用「按鈕」參數(保持風格一致),你不應該有問題迫使提交表單與javascript函數(){$(「#表格名稱「)提交()。 }

我建議做一個ajax調用來完成提交,並用.success或.error處理程序來捕獲它,以進行下一步。

你必須在更新你創建的模態div上工作很多。只有在成功後關閉它。