Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contain form within a bootstrap popover?

<div class="container">     <div class="row" style="padding-top: 240px;">         <a href="#" class="btn btn-large btn-primary" rel="popover"             data-content="<form><input type="text"/></form>"             data-placement="top" data-original-title="Fill in form">Open form</a>     </div> </div> 

JSfiddle

I'm guessing that I would store the form contents within a javascript function...

How do I contain a form within a bootstrap popover?

like image 965
user1438003 Avatar asked Aug 26 '12 07:08

user1438003


People also ask

How do I style bootstrap popover?

If you have multiple popovers on your page and only want to style one of them, you can leverage the popover's template option to add another class: $("#myElement"). popover({ template: '<div class="popover my-specific-popover" role="tooltip">...' });

What is the difference between Tooltip and popover?

Tooltip: use tooltips to show a short text to respondents when they hover over a word or icon. Popover: use popovers to show a longer text, or when you want to have a link to an external web page. It is shown when the respondent clicks on a word or icon.

How does bootstrap define popover?

A Bootstrap Popover is an attribute in bootstrap that can be used to make any website look more dynamic. Popovers are generally used to display additional information about any element and are displayed with a click of a mouse pointer over that element.


1 Answers

I would put my form into the markup and not into some data tag. This is how it could work:

JS Code:

$('#popover').popover({      html : true,     title: function() {       return $("#popover-head").html();     },     content: function() {       return $("#popover-content").html();     } }); 

HTML Markup:

<a href="#" id="popover">the popover link</a> <div id="popover-head" class="hide">   some title </div> <div id="popover-content" class="hide">   <!-- MyForm --> </div> 

Demo

Alternative Approaches:

X-Editable

You might want to take a look at X-Editable. A library that allows you to create editable elements on your page based on popovers.

X-Editable demo

Webcomponents

Mike Costello has released Bootstrap Web Components. This nifty library has a Popovers Component that lets you embed the form as markup:

<button id="popover-target" data-original-title="MyTitle" title="">Popover</button>  <bs-popover title="Popover with Title" for="popover-target">   <!-- MyForm --> </bs-popover> 

Demo

like image 134
HaNdTriX Avatar answered Oct 03 '22 18:10

HaNdTriX