[eluser]stathis[/eluser]
Hi , it's me again.
I would like your advice on implementing the following:
I have a form for a cms system, that displays the fields of a database table(products).
Inside the form, i have a datagrid that populates some related records from another table(product_images).
I've build the datagrid in such way , that each record is populated into input boxes, and it has 2 links, one for edit, one for delete.
Each of these links has a onclick function assigned, that calls a function by passing the record's id to it. For example:
Code:
<table>
<tr id="row_id_1">
<td>
<input id="image_id_1" value="productimage1.jpg"/>
</td>
<td>
<a href="#" id="image_edit_1">edit</a>
<a href="#" id="image_delete_1">delete</a>
</td>
</tr>
<tr id="row_id_2">
<td>
<input id="image_id_2" value="blalbla.jpg"/>
</td>
<td>
<a href="#" id="image_edit_2">edit</a>
<a href="#" id="image_delete_2">delete</a>
</td>
</tr>
</table>
The javascript function is like this:
Code:
function ajax_function(id,action){
img=document.getElementById("image_id_"+id).value;
$.ajax({
type: "POST",
url: base_url + "index.php/mycontroller/mytacofunction/"+ id,
data:{ image_name: img, action: action}
});
}
The question comes to the point where i need to use the taco class to reload this content, and set the onclick functions using the eval functionallity
Do i need to specify eval functionality for the links of each row of the datagrid?
For example:
Code:
$this->taco->set('eval', "$('#image_edit_1').click(function () {ajax_function(1,'edit')};");
$this->taco->set('eval', "$('#image_delete_1').click(function () {ajax_function(1,'delete')};");
$this->taco->set('eval', "$('#image_edit_2').click(function () {ajax_function(1,'edit')};");
$this->taco->set('eval', "$('#image_delete_2').click(function () {ajax_function(2,'delete')};");
Could you please advice?
Thanks in advance,
Stathis