EFuerte EFuerte - 1 month ago 6
JSON Question

Could you point how to put a button at the right side of the links by using jQuery?

I'm very new here.

Could you point how to put a functional button at the right side of the links by using jQuery?

Site's picture

Accordingly to:

if(field ==="anexo_v"){
if(value !==null){
$(".anexo_v").show();
var link = "";
$.each(value,function(id, valor){
var anexo = valor.anexo;
anexo = anexo.split("/");
anexo = $(anexo).get(-1);
//console.log(valor.anexo);
link = link+"<p><a href=\'"+valor.anexo+ "\' target=\'_blank\'>"+anexo+"</a></p>"; ;
});
$("#anexo").html(link);
}else{
$(".anexo").hide();
}
}


Plus - this button needs to call, by Ajax, a PHP Codeigniter's controller to perform a deletion (Excluir means deletion).

Thanks in advance!

Answer

Change

link = link+"<p><a href=\'"+valor.anexo+ "\' target=\'_blank\'>"+anexo+"</a></p>";

to

link = link+"<p style=\'display:inline\'><a href=\'"+valor.anexo+ "\' target=\'_blank\'>"+anexo+"</a></p><button value=\'Excluir\' onclick=\'functionToMakeAjaxCall("+valor.anexo+")\'></button>";

and add

function functionToMakeAjaxCall(parameter){
    //code to make ajax call to a controller to delete
}
Comments