I have a table
that has a td
with the following code:
.append($("<td class='popOverStatusAlmo' data-container='body' data-toggle='popover' data-placement='top' data-content='" + this.StatusAlmoxarifado + "' style='color:red'></td>").text(this.StatusAlmoxarifado != "" ? this.StatusAlmoxarifado.toUpperCase().substring(0, 15) + "..." : this.StatusAlmoxarifado));
Every time the user hover over td
I trigger an event of mouseenter
and show popover
.
Only in this same table
the user can change the status that is shown in popover
.
if ($(e.target).hasClass("fa-pencil-square-o")) {
$this = $(e.target).parent().parent();
$("#txbMyModalStatusAlmoxarifado").val($($this).find("td:nth-child(7)").data("content"));
$("#myModalStatusAlmoxarifado").modal("show");
}
Notice that I get the value of data("content")
and put this value in textarea
to be able to edit. And that's where my problem starts.
When I save the edited information, I enter the val()
of textarea
into attr data
.
$("#btnModalStatusAlmoxarifado").click(function () {
var linha = $this;
var comentario = $("#txbMyModalStatusAlmoxarifado").val();
var pim = $(linha).find("td:nth-child(1)").text();
modificarStatusAlmoxarifado(pim, comentario);
$(linha).find("td:nth-child(7)").text(comentario.toUpperCase().substring(0, 15) + "...");
$(linha).find("td:nth-child(7)").data('content', 'ANDERSON');
$('[data-toggle="tooltip"]').tooltip();
});
I put Anderson to test.
It seems to work, because if I click to edit it takes Anderson to textarea
of modal
, but if I hover over the field it shows the old value and not what I saved.
Is there any way to update popver
so it shows the new value without having to reload the entire screen?