Popover Function – Twitter Bootstrap

Just a quick post on how easy it is to implement a popover with twitter bootsrap:

JavaScript:

//Create tooltips for login/signup forms
function create_tooltips(){

    //Create vars
    var titles = ['test title']
    var contents = ['test content'];
    var fields = ['#user_email'];

    //Loop through each field and assign tooltip
    for(var i = 0; i < fields.length; i++){

        //Create vars
        var field = $(fields[i]);
        var title = titles[i];
        var content = contents[i];

        //Ensure field found
        if(field){

            //Create popover
            $(field).popover(
                {
                    animation: true,
                    placement: 'right',
                    selector: false,
                    trigger: 'hover',
                    title: title,
                    content: content,
                    delay: 0
                });
        }
    }
}

Form:

  
resource_name, :url => registration_path(resource_name), :class => 'form-vertical') do |f| %>
'btn btn-success' %>

Result:

Popover - Twitter Bootstrap

Popover - Twitter Bootstrap

That’s all there is to it, if you haven’t had a chance to check it out yet make sure you head on over to the official site – there are some pretty neat features.

Advertisements

One thought on “Popover Function – Twitter Bootstrap

  1. Pingback: Cameron Stitt

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s