Как настроить поведение функции оповещения по умолчанию для оповещения qtip 2
Я использую qtip2 для отображения сообщений с предупреждениями для моего веб-приложения (как показано на http://craigsworks.com/projects/qtip2/demos/)
мой код
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");
как сделать, чтобы мое настраиваемое оповещение имитировало функцию оповещения по умолчанию? Пожалуйста помоги
1 ответ
Замещать
ok = $('<button />', { text: 'Ok', 'class': 'full' });
с
ok = $('<button />', { text: 'Ok', 'class': 'full' }).click(function(){
window.location.replace("/Home/startPage");
});