jquery-tabledit icon indicating copy to clipboard operation
jquery-tabledit copied to clipboard

Need to refresh manually the page after delete row

Open luckyzor opened this issue 6 years ago • 3 comments

I need to refresh manually (F5) to the row disappear

Can you help me?

$(document).ready(function(){
$('#editable_table').Tabledit({ url:'action.php', hideIdentifier: true, columns:{ identifier:[0, "product_id"], editable:[[6, 'product_stock']] }, restoreButton:false, onSuccess:function(data, textStatus, jqXHR) { if(data.action == 'delete') { $('#'+data.id).remove(); } } }); });

action.php

if($input["action"] === 'delete') { $query = " DELETE FROM product WHERE product_id = '".$input["product_id"]."' "; mysqli_query($conn, $query); }

echo json_encode($input);

luckyzor avatar Sep 12 '18 09:09 luckyzor

Deleted rows get a class of 'tabledit-deleted-row' added, so in my onSuccess event, I just call remove() on any element that has that class.

$('.tabledit-deleted-row').remove();

This seemed to work well enough for what I'm doing. it is removed in the database so when the page is reloaded, it won't show up anyway.

raynebair avatar Nov 28 '18 15:11 raynebair

I'm having the same problem as luckyzor, and i'm not understanding raynebair answer entirely.

Is this the OnSuccess spot where I should use that code? It didn't refresh my table after delete confirmation

					<tbody>
						 <?php
							 while($row = mysqli_fetch_array($result)){
								 echo '
									 <tr>
										 <td>'.$row["Id"].'</td>
										 <td>'.$row["NIF"].'</td>
										 <td>'.$row["Nome"].'</td>
										 <td>'.$row["Tipo"].'</td>
										 <td>'.$row["Morada"].'</td>
										 <td>'.$row["CodPostal"].'</td>
										 <td>'.$row["Localidade"].'</td>
									 </tr>';
							 }
						 ?>
					</tbody>
				</table>
			</div>
		</div>
	</body>  
</html>  
<script>  
	$(document).ready(function(){  
		$('#editable_table').Tabledit({
			url:'instituicoes_action.php',
			  columns:{
			  identifier:[0, "Id"],
			  editable:[[1, 'NIF'], [2, 'Nome'], [3, 'Tipo'], [4, 'Morada'], [5, 'CodPostal'], [6, 'Localidade']]
			},
			restoreButton:false,
			onSuccess:function(data, textStatus, jqXHR){
				if(data.action == 'delete'){
					$('#'+data.id).remove();
		   		}
			}
		});
	});
</script>

david-sottomayor avatar Oct 19 '19 21:10 david-sottomayor

@raynebair, that works great!

lavaca92 avatar Nov 22 '22 20:11 lavaca92