2012-01-10 2 views
0

jquery 사용자 모달 양식을 통해 이미지를 업로드하려고합니다.jquery 사용자 모달 양식을 통해 이미지 업로드

가능합니까? 내가

사람이 그것에 대해 어떤 생각을해야합니까 ..

내가 그물을 통해 검색되었지만 명확한 답이 없다 .. 모달의 값을 얻는 방법에 문제가 있습니다?

이 모달 양식에 대한 내 자바 스크립트 코드 :

<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

나는 당신이 "버튼"매개 변수를 사용하지 않는 게 좋을 것, 이 내 모달 폼이

$("#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"); } 
            } 
      }); 
       }); 

입니다

대신 폼에 업로드 단추를 만드십시오.

아무 것도하지 않으면 양식이 설정된 동작이로드됩니다.


당신이 정말로 (같은 스타일을 유지하기 위해)은 "버튼"매개 변수를 사용하려는 경우, 당신은 문제가() 자바 스크립트 함수와 양식의 제출을 ​​강요하지 말았어야 {$ ("# formName "). submit(); }

제출을 위해 ajax 호출을 수행하고 .success 또는 .error 처리기로 catch하여 다음 단계를 수행하는 것이 좋습니다.

작성한 모달 div를 업데이트 할 때 많은 작업을해야합니다. 그리고 .success 후에 만 ​​닫습니다.