Skip to content

Instantly share code, notes, and snippets.

View ruancarvalho's full-sized avatar

Ruan Carvalho ruancarvalho

View GitHub Profile
(function($) {
remove = function(item) {
var tr = $(item).closest('tr');
tr.fadeOut(400, function() {
tr.remove();
});
return false;
}
<table id="details-table" class="table table-bordered">
<tr>
<th>Coluna 1</th>
<th>Coluna 2</th>
<th>Coluna 3</th>
<th>Coluna 4</th>
<th>Opções</th>
</tr>
<tr>
<td>&nbsp;</td>
<div class="container">
<h1 class="page-header">Tabelas com Bootstrap</h1>
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>#</th>
<th>Coluna 01</th>
<th>Coluna 02</th>
<th>Coluna 03</th>
<?php
/**
* Remove uma linha de uma tabela pelo ID do registro
*/
function remove( $table = null, $id = null ) {
$database = open_database();
try {
if ($id) {
<?php
require_once('functions.php');
if (isset($_GET['id'])){
delete($_GET['id']);
} else {
die("ERRO: ID não definido.");
}
?>
/**
* Passa os dados do cliente para o Modal, e atualiza o link para exclusão
*/
$('#delete-modal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var id = button.data('customer');
var modal = $(this);
modal.find('.modal-title').text('Excluir Cliente #' + id);
@ruancarvalho
ruancarvalho / modal.php
Created October 7, 2016 15:35
Exemplo de Modal de Exclusão com Bootstrap
<!-- Modal de Delete-->
<div class="modal fade" id="delete-modal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Fechar"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="modalLabel">Excluir Item</h4>
</div>
<div class="modal-body">
Deseja realmente excluir este item?
<?php
/**
* Exclusão de um Cliente
*/
function delete($id = null) {
global $customer;
$customer = remove('customers', $id);
header('location: index.php');
<?php
require_once('functions.php');
view($_GET['id']);
?>
<?php include(HEADER_TEMPLATE); ?>
<h2>Cliente <?php echo $customer['id']; ?></h2>
<hr>
@ruancarvalho
ruancarvalho / functions.php
Last active November 20, 2017 02:31
Exemplo de função de visualização de registro
<?php
/**
* Visualização de um Cliente
*/
function view($id = null) {
global $customer;
$customer = find('customers', $id);
}