开发者

supermodal change behavior of cancel

sorry for the noob question, but is it possible to redirect to a url by clicking cancel in addition to just closing the dialog? TIA.

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) {
开发者_Python百科        var modal = this;

        $('.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() ; // or $.modal.close();
        });
    }
});


I'm not familiar with the jQuery modal dialog, but it looks like you can just modify this line:

closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",

to change the href attribute:

closeHTML: "<a href='http://google.com' title='Close' class='modal-close'>x</a>",

However, the modal dialog close handler likely cancels the default action (in this case, going to Google), so you can just add:

location.href("http://google.com")

after closing the dialog (modal.close();)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜