Confirm tooltip dialog with qTip2?

感情迁移 提交于 2019-12-10 17:20:17

问题


So, i'm trying to create a small confirmation dialog (inline, toopltip) when a user clicks a delete button.

I imagine it to look kinda like this

(but with a small text and OK & Cancel buttons). But i'm not here to ask how to style it.

I would prefer to use qTip2 as the plugin for the job, but if you have an better alternative i'd go for it too.

So, how would i do to launch a tooltip with some interatice elements and only close it if looses focus or the close button is clicked. Also - the delete button is loaded by Ajax.

Any ideas?

Thank you, peace!


回答1:


It is easy to do with qTip2. I will give you a start, for that see my DEMO

Result

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());
    });
});​

Please for better adjusting to your needs, read the qTip2 Documentation and the jQuery UI Documentation.



来源:https://stackoverflow.com/questions/6095399/confirm-tooltip-dialog-with-qtip2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!