2010-08-02 127 views
1

點擊jsp中的「刪除」鏈接後,我有一個確認框。現在問題是成功刪除頁面顯示在同一個窗口中。jquery確認後的jquery彈出窗口

我想在彈出的窗口中顯示它。

我試圖使用javascript onclick(),但它不是wotking。那麼,我該怎麼做?

<script type="text/javascript" src="jquery-1.4.2.min.js"></script> 
<script type="text/javascript" src="jconfirmaction.jquery.js"></script> 


<script type="text/javascript"> 

      $(document).ready(function() { 


       $('.ask-plain').click(function(e) { 

        e.preventDefault(); 
        thisHref = $(this).attr('href'); 

        if(confirm('Delete this record?')) { 
         window.location = thisHref; 
        } 

       }); 

       $('.ask-custom').jConfirmAction({question : "Anda Yakin?", yesAnswer : "Ya", cancelAnswer : "Tidak"}); 
       $('.ask').jConfirmAction(); 
      }); 

     </script> 

<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 


<SCRIPT TYPE="text/javascript"> 
<!-- 
function popup(mylink, windowname) 
{ 
if (! window.focus)return true; 
var href; 
if (typeof(mylink) == 'string') 
    href=mylink; 
else 
    href=mylink.href; 
window.open(href, windowname, 'width=750,height=430,scrollbars=no'); 
return false; 
} 
//--> 
</SCRIPT> 

---Delete image 
<td width="3%" align="left"><a href="cir_delete.jsp?cir_id=<%=rs.getString("cir_id")%>" class="ask"><IMG SRC="12.png" ALT="Delete" BORDER="0"></a></td> 

感謝名單

當你點擊刪除
+0

我沒有看到任何代碼? – Ties 2010-08-02 08:41:46

+0

爲什麼我感覺這個問題與[jconfirm-form-submit-returns-incorrect-value-to-php]類似的問題(http://stackoverflow.com/questions/3385574/jconfirm-form-submit-returns -incorrect-value-to-php)。一些功課? – Reigel 2010-08-02 08:50:21

+0

這是有點不同 – maas 2010-08-02 09:35:51

回答

0

,顯示確認對話框,之後的形式提交。

你需要做的是提交表單槽jquery,cathc的結果並顯示傳遞給一個彈出框。我會很快給出一個例子。

我與jconfirm做過一次:

<script type="text/javascript"> 
     $(document).ready(function(){ 
      // give all your delete links a class="del" then when this is clicked, execute following: 
      $(".del").click(function() { 
      //get the href from th link you clicked 
      var href = $(this).attr("href"); 
       activate JConfirm 
       jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) { 
        // if confirm is clicked: 
        if(r){ 
         //post the form serialised to the url 
         $.post(href, $("#yourtestform").serialize(), 
          function(data){ 
          // the posted form will return html data, load this data in a hidden div 
          $('#loadhtml').html = data; 
          // now that the data is loaded, open a colorbox with the hidden div as content (don't forget to include the colorbox.js 
          $('#loadhtml').colorbox(); 
          }; 
         ); 
        } 
        //if the person clicked cancel: do nothing 
        else{ 
         return false; 
        } 
       }); 
       // insure that the form doesn't post itself again after jquery is finished 
       return false; 
      }); 
     }); 
    </script> 

我假設你想用一個模式彈出像colorbox什麼 在底部,您可以在後門柱加載HTML和隱藏定義一個div它:

<div style="display:hidden" id="loadhtml"> 
</div> 
+0

對不起,你能請多解釋一下 //調用彈出框函數加載html ,因爲我有點困惑 – maas 2010-08-02 09:35:04

+0

現在,我應該完全刪除我的代碼嗎?並將其替換爲您發佈的那個? – maas 2010-08-02 10:28:33

+0

我添加了一些評論,它可能不是語法正確的,因爲我只是在這裏寫的,並沒有在瀏覽器或任何東西中測試它。但我確信基礎知識將起作用並且流程將起作用 – Nealv 2010-08-02 11:47:27

0

如果你需要最高級的版本 - jconfirmaction.jquery.js,將分享給你。