I have a list of items and each item in this list is a link with a lot of attributes and items within that link.
summarizing my link is like this:
<a href="#" class="editItem list-group-item" data-id="1001" data-validate="2014-09-08">
<h4>Meu Item</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</a>
What I'm doing is that I click on this item, then it opens a modal that has a form that the user fills in that form and when saving I should update this item, but remembering that I have to change the <a>
integer because can have attributes of it altering and texts as well.
I've already done all the ajax part, it's sending right, I just can not really replace it.
I tried something like
$.ajax({
type : 'POST',
url : 'pagina.php',
data : dados,
success : function ( html ) {
var itens = $("a.editItem");
$.each(itens, function(i, item) {
// item_id é uma variavel que tenho que da o item clicado
if ( $(item).data('id') == item_id ) {
// AQUI ESTA O MEU PROBLEMA
$(item).before(html);
$(item).remove();
}
});
}
});