4
I have a modal window in bootstrap, and inside it a pagination, it happens that every time I click on some pagination link, the modal closes. Does anyone know how I keep the modal open?
jQuery:
$.post("busca-usuarios.php", {busca: busca, id_profile: id_profile},function(data) {
  $("#user-data").html(data);
});
PHP:
<?php
include realpath(dirname(__FILE__)) . '/includes/init.php';
include realpath(dirname(__FILE__)) . '/includes/function.php';
include realpath(dirname(__FILE__)) . '/includes/class.paginacao.php';
//include realpath(dirname(__FILE__)) . '/includes/sistema.paginacao.php';
$paginaAtual = fRequest::get('paginaAtual');
if (!isset($paginaAtual)) {
    $paginaAtual = 1;
}
$busca = fRequest::get('busca');
$id_profile = fRequest::get('id_profile');
$profile = listaPerfis($id_profile);
$array = fRecordSet::build('FidUser', array('display_name~' => $busca),     array(), 20, $paginaAtual);
$total = fRecordSet::build('FidUser', array('display_name~' => $busca));
$link = "sistema-edit.php?profile=" . $id_profile . "&busca=" . $busca .     "&paginaAtual=";
$count = $total->count();
echo '<table class="table table-striped table-hover tablesorter table-    instituicao-usuario-list table-obra-list">';
echo '
<thead>
  <th>Nome</th>
  <th>E-mail</th>
  <th>Perfil</th>
  <th class="text-center">Adicionar</th>
</thead>';
echo "<tbody>";
foreach ($array as $key => $nome) {
    echo "<tr>";
    echo "<td><h5><a href='usuario-edit.php'>" . $nome->getDisplayName() . "</a></h5><input type='hidden' name='hidden_id_profile' value='" . $nome->getFidUserId() . "'/>";
    echo "<td>" . $nome->getUserEmail() . "</td>";
    echo "<td><select name='select_profile' id='select_profile' class='form-control'><option value='0' selected='selected'>Selecione</option>";
    for ($i = 0; $i < count($profile); $i++) {
        echo "<option value='" . $profile[$i]['id'] . "'>" . $profile[$i]    ['name'] . "</option>";
    }
    echo "</select></td>";
    echo "<td class='text-center'><a class='btn btn-success btn-xs' href='#'><span class='glyphicon glyphicon-plus'></span></a></td>";
    echo "</tr>";
}
echo "</tbody>";
echo "<table id='pag'><tr><td>" . Paginacao::pagination($count, count($array), 10, $paginaAtual, $link, 20) . "</td></tr></table>";
?>
Class:
class Paginacao {
    static function pagination($count, $total, $max, $current, $link, $size = 0) {
        $total = intval($total);
        $max = intval($max);
        $current = intval($current);
        $size = intval($size);
        $numbers = ceil($count / 20);
        $pages = ceil($total / $max);
        $preview = $current === 1 ? "" : "<li><a href=\"" . $link . ($current - 1) . "\" class=\"previous-link\">Anterior</a></li>";
        if ($total > 0) {
            $next = $current === $pages ? "" : "<li><a href=\"" . $link . ($current + 1) . "\" class=\"next-link\">Próximo</a></li>";
        } else {
            $next = "";
        }
        $return = "<div id=\"pagination\" class=\"text-center\"><ul class=\"pagination\">";
        $return.= $preview;
        for ($i = 1; $i <= $numbers; $i++) {
            $return .= "<li><a href='" . $link . $i . "'>" . $i . "</a></li>";
        }
        $return.=$next;
        $return.= "</ul></div>";
        return $return;
    }
}
Can you include your code? If possible, a small example that reproduces the problem.
– bfavaretto
Are your pagination links being followed? (That is, the page reloads?) If it does not reload, you missed posting the relevant javascript.
– bfavaretto
Then the page reloads, knowing how to avoid it
– Daniel Swater