3
I have a list of items and each item on that list is a link with a lot of attributes and items within that link.
summarizing my link 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 am doing is that I click on this item, then opens a modal that has a form that the user fills this form and when saving I should update this item, but remembering that I have to change the <a>
whole, for it may have attributes of it that alter and the texts as well.
I’ve done all the ajax part, this sending right, I’m just not able to replace even.
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();
}
});
}
});
And what do you get from ajax? HTML with a new element? o
data-id
of the element?– Sergio
ajax return is html with the item
<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>
but that item can have different date-validate and text as well, already the data-id is the same– Marcelo Diniz
And that element you receive from ajax should override the right click?
– Sergio
that’s right, I thought to remove the clicked item and then put the return in place because I have other items and with that the user knows what he changed and just continues the list
– Marcelo Diniz