Confirm tooltip dialog with qTip2?
Asked Answered
S

1

4

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

enter image description here

(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!

Selassie answered 23/5, 2011 at 9:38 Comment(0)
S
2

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

Result

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

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

Sanferd answered 6/5, 2012 at 21:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.