2010-01-28 43 views
2

我試圖暗示一個確認框,但我需要使用html編輯文本。所以,我發現jQuery的「確認覆蓋」在這裏: http://www.ericmmartin.com/projects/simplemodal-demos/需要幫助在jQuery模式對話框中輸入html

他提到這裏大約有造型HTML字符串: http://www.ericmmartin.com/projects/simplemodal/

但我不inderstand凡在我的功能,我該怎麼辦呢?這裏是功能:

$(document).ready(function() { 
    $('#confirm-dialog input.confirm, #confirm-dialog a.confirm').click(function (e) { 
     e.preventDefault(); 

     // example of calling the confirm function 
     // you must use a callback function to perform the "yes" action 
     confirm("Continue to the SimpleModal Project page?", function() { 
      window.location.href = 'http://www.ericmmartin.com/projects/simplemodal/'; 
     }); 
    }); 
}); 

function confirm(message, callback) { 
    $('#confirm').modal({ 
     closeHTML:"<a href='#' title='Close' class='modal-close'>x</a>", 
     position: ["20%",], 
     overlayId:'confirm-overlay', 
     containerId:'confirm-container', 
     onShow: function (dialog) { 
      $('.message', dialog.data[0]).append(message); 

      // if the user clicks "yes" 
      $('.yes', dialog.data[0]).click(function() { 
       // call the callback 
       if ($.isFunction(callback)) { 
        callback.apply(); 
       } 
       // close the dialog 
       $.modal.close(); 
      }); 
     } 
    }); 
} 

謝謝你的幫助!

基本上而不是確認(「繼續到SimpleModal項目頁面?」,()的函數我必須療法無序列表服務(條款)

回答

1

您是否嘗試過通過HTML作爲第一個參數?

您的代碼應該做工精細這樣

confirm('<ul><li>somedata</li><li>moredata</li></ul>', function(){}); 

,因爲您的確認功能追加message變量。

+1

這做到了。AWES青梅。非常感謝! – Joel 2010-01-28 04:08:31