【问题标题】:how to give default alert function behaviour to qtip 2 alert如何为 qtip 2 警报提供默认警报功能行为
【发布时间】:2013-03-27 21:13:53
【问题描述】:

我正在使用 qtip2 来显示我的 Web 应用程序的警报消息(如 http://craigsworks.com/projects/qtip2/demos/#dialogues 所示)

我的代码是

1) 对话

function dialogue(content, title) {
    /* 
    * Since the dialogue isn't really a tooltip as such, we'll use a dummy
    * out-of-DOM element as our target instead of an actual element like document.body
    */
    $('<div />').qtip(
                {
                    content: {
                        text: content
                       , title: {
                           text: 'PMGSY ',
                           button: 'Close'
                       }
                    },
                    position: {
                        my: 'center', at: 'center', // Center it...
                        target: $(window) // ... in the window
                    },
                    show: {
                        ready: true, // Show it straight away
                        modal: {
                            on: true, // Make it modal (darken the rest of the page)...
                            blur: false, // ... but don't close the tooltip when clicked
                            escape: false
                        }
                    },
                    hide: false, // We'll hide it maunally so disable hide events

                    style: {
                        classes: 'qtip-shadow qtip-rounded qtip-dialogue', // Optional shadow...
                        widget: true //themeroller
                    },

                    events: {
                        // Hide the tooltip when any buttons in the dialogue are clicked
                        render: function (event, api) {
                            $('button', api.elements.content).click(api.hide);
                        },
                        // Destroy the tooltip once it's hidden as we no longer need it!
                        hide: function (event, api) { api.destroy(); }
                    }
                });
}

2) 将其称为警报

function Alert(message) {
    // Content will consist of the message and an ok button
    var message = $('<p />', { text: message }),
    ok = $('<button />', { text: 'Ok', 'class': 'full' });
    dialogue(message.add(ok), 'Alert!');
}

问题是当我使用它时,它不会阻止进一步处理,直到用户单击确定按钮(如默认警报功能)。

例如,此警报甚至不显示。

Alert("Customised alerts"); //this doesent show      
window.location.replace("/Home/startPage");

如何让我的自定义警报模仿默认警报功能? 请帮忙

【问题讨论】:

    标签: javascript qtip qtip2


    【解决方案1】:

    替换

    ok = $('<button />', { text: 'Ok', 'class': 'full' });
    

    ok = $('<button />', { text: 'Ok', 'class': 'full' }).click(function(){
        window.location.replace("/Home/startPage");
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-14
      • 1970-01-01
      • 2022-11-07
      • 2012-05-16
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多