I have a table with several inputs together and I use the Tooltip plugin of Jquery UI
, to display a message when the fields are required, my problem is in the position of the tooltips that appear one on top of the other and what I want is for each tooltip to be seen in its entirety. each input.
This is how it looks now:
I've been reading the Position api of Jquery UI
, option-Position , but I can't find the solution.
js code:
$(input).tooltip({
content: mensaje,
items: "input.obligatorio",
track: true,
show: true,
tooltipClass: "tooltip-error"
});
HTML:
<div class="col-xs-5" style="height: 103px;">
<table class="table">
<thead class="text-center">
<tr class="cabeceraDos">
<th>
Columna 1
</th>
<th>
Columna 2
</th>
<th>
Columna 3
</th>
<th>
Columna 4
</th>
<th>
Columna 5
</th>
<th>
Columna 6
</th>
<th>
Columna 7
</th>
<th>
Columna 8
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<asp:TextBox runat="server" CssClass="form-control obligatorio" MaxLength="1" ID="txt_column1"></asp:TextBox>
</td>
<td>
<asp:TextBox runat="server" CssClass="form-control obligatorio" MaxLength="1" ID="txt_column2"></asp:TextBox>
</td>
<td>
<asp:TextBox runat="server" CssClass="form-control obligatorio" MaxLength="1" ID="txt_column3"></asp:TextBox>
</td>
<td>
<asp:TextBox runat="server" CssClass="form-control obligatorio" MaxLength="1" ID="txt_column4"></asp:TextBox>
</td>
<td>
<asp:TextBox runat="server" CssClass="form-control obligatorio" MaxLength="1" ID="txt_column5"></asp:TextBox>
</td>
<td>
<asp:TextBox runat="server" CssClass="form-control obligatorio" MaxLength="1" ID="txt_column6"></asp:TextBox>
</td>
<td>
<asp:TextBox runat="server" CssClass="form-control obligatorio" MaxLength="1" ID="txt_column7"></asp:TextBox>
</td>
<td>
<asp:TextBox runat="server" CssClass="form-control obligatorio" MaxLength="1" ID="txt_column8"></asp:TextBox>
</td>
</tr>
</tbody>
</table>
</div>
As you indicate in the question, you can use the position option (
position
) to indicate where the tooltip will be displayed. The position is an object that contains different values ( source ) of the ones you are interested inat
andmy
.One possibility is to change the code a bit so that this position is added:
But this would not be enough because since they all
input
have the same value they continue to be mounted on top of each other. So, what should be done is to change the code a bit more so thatinput
even tooltips are displayed in one position, while odd ones are displayed in another. For it:Thus they are displayed at different heights (although some may still overlap). An example:
You could play with the variable
index
to position the tooltip where you want depending on its value. Alternatively, you could also create your own styles and add themtooltipClass
inside theeach
.You can use CSS to solve it:
Applying one more class to identify each cell, similar to the zebra strategy in a table style:
And have two different loads
In this example the tooltip is loaded a little lower. I hope it helps you
Here a jsfiddle