使用qTip2确认提示框对话框?

4

所以,我正在尝试创建一个小的确认对话框(内联,工具提示),当用户点击删除按钮时。

我想象它看起来有点像这样

enter image description here

(但只有一些文本和“确定”和“取消”按钮)。 但我不是来问如何为其设置样式的。

我倾向于使用qTip2插件完成此工作,但如果你有更好的替代方案,我也可以考虑。

那么,我应该如何启动带有一些交互元素的工具提示,并仅在失去焦点或单击关闭按钮时关闭它。同时 - 删除按钮是通过Ajax加载的。

有什么想法吗?

谢谢,祝好!

1个回答

2
这很容易使用qTip2完成。我会给你一个起点,可以查看我的DEMO

结果

Demo pic

HTML

<button id="gear">Gear</button>
<div style="display:none;" id="menu">
    <div class="menuitem">Rename</div><br>
    <div class="menuitem">Duplicate</div><br>
    <div class="menuitem">Delete</div><br>
</div>

CSS

#gear {
    margin:100px;
}
.menuitem {
    padding-left: 10px;
    padding-right: 10px;
    font-size: 9px;
    margin-bottom: 3px;
    width: 75px;
}

JavaScript
$(function() {
    $("#gear").button({
        icons: {
            primary: "ui-icon-gear",
            secondary: "ui-icon-triangle-1-s"
        },
        text: false
    }).qtip({
        content: {
            text: $('#menu')
        },
        show: {
            event: 'click',
            solo: true,
            modal: true
        },
        style: {
            classes: 'ui-tooltip-dark ui-tooltip-shadow'
        },
        position: {
            my: 'top center',
            at: 'bottom center',
        }
    });
    $(".menuitem").button().click(function(){
        alert($(this).text());
    });
});​

为了更好地适应您的需求,请阅读 qTip2文档jQuery UI文档

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接