2008-09-08 48 views
9

我想在UI工具包中使用像簡單模式或對話框加載項那樣的加載項。但是,如何使用這些或其他方法並返回結果。基本上我希望模式與服務器做一些Ajax交互,並返回調用代碼的結果來做一些事情。謝謝。如何從JQuery中的模式對話框中獲取結果

回答

0

由於模式對話框位於頁面上,因此您可以自由設置所需的任何文檔變量。然而,我所見過的所有模態對話框腳本都包含一個使用返回值的演示,因此它可能在該頁面上。

(該網站被封鎖我,否則我想看看)

5

下面是確認窗口的工作原理上simpleModal:

$(document).ready(function() { 
    $('#confirmDialog input:eq(0)').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({ 
    close: false, 
    overlayId: 'confirmModalOverlay', 
    containerId: 'confirmModalContainer', 
    onShow: function (dialog) { 
     dialog.data.find('.message').append(message); 

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

這可悲的似乎不再工作... – 2011-06-01 14:44:38

相關問題