Welcome Guest, Not a member yet? Register   Sign In
ajax pagination + protoype?
#1

[eluser]MMCCQQ[/eluser]
trying build a ajax pagination with Prototype for my Gallery!

i got this! ,,work it! but i need to know how show Prev,Next and 1,2,3,4...Page Link

Controller

Code:
function Gethumb(){
// URL type: http://importzona.com/Gethumb/num of page
        $this->empezar = $this->uri->segment(3);
        $this->db->limit(1,$this->empezar);
        $this->db->order_by('id','desc');
        $Resultado = $this->db->get('album_photo');
        echo $this->uri->segment(3);
         foreach ($Resultado->result_array() as $row)
       {
          echo "<div id='thumb_wrap'>";
          echo "<div id='thumb'><img src='http://beta.importzona.com/".$row['thumb']."'></div>";
          echo "</div>";
          
       }


        
        
        
        
        
    }

View
Quote:




function get(id){
if($("sidebar")){

new Ajax.Request(
'Gethumb/'+id,

{


method:"post",
onComplete: procesaRespuesta


}
);

};
}

function procesaRespuesta( resp ){


$("sidebar")[removed] = resp.responseText;
}

&lt;a href="#" onclick="get('2');"&gt;Push Me!</a>
<div id="sidebar">
</div>
#2

[eluser]MMCCQQ[/eluser]
nobody?....
#3

[eluser]Nick Husher[/eluser]
You will need to collect information on how many photographs you have. There's a way of doing a count of the number of records in the table without actually calling count, and I seem to remember a few threads on that topic on this forum. You'll then need to hand that information either to your view when the page loads, or to your javascript widget as you change the page. At the moment, you're sending just the code for the image, but you could also pass along the pagination information as well:
Code:
<div id='thumb_wrap'>
<div id='thumb'><img src='http://beta.importzona.com/IMAGE_HREF'></div>;
</div>
&lt;a href="#" onclick="get('PAGE_NUMBER - 1')"&gt; << Previous </a>
CURRENT_PAGE of ROW_COUNT
&lt;a href="#" onclick="get('PAGE_NUMBER + 1')"&gt; Next >></a>

You need to replace the capitalized keywords with your calculated values, of course. Also, you might want to think about switching to some more-unobtrusive javascript. Onclicks are so 1999. Wink
#4

[eluser]MMCCQQ[/eluser]
i did it , well... but dont work in Explorer 7

Code:
function Gethumb(){
        $this->RegistrosAMostrar=21;
if($this->uri->segment(3)){
  $this->RegistrosAEmpezar=($this->uri->segment(3) - 1)* $this->RegistrosAMostrar;
  $this->PagAct=$this->uri->segment(3);
  //caso contrario los iniciamos
}else{
  $this->RegistrosAEmpezar=0;
  $this->PagAct=1;
}

        $this->empezar = $this->uri->segment(3);
        $this->db->limit($this->RegistrosAMostrar,$this->RegistrosAEmpezar);
        $this->db->order_by('id','desc');
        $this->db->where('idalbum','21');
        $Resultado = $this->db->get('album_photo');
        echo ($this->uri->segment(3) - 1)* $this->RegistrosAMostrar;
     echo "<div id='album' style='width:300px;'>";
         foreach ($Resultado->result_array() as $row)
       {
        
          echo "<a href='#'><img width='98' src='http://beta.importzona.com/".$row['thumb']."'></a>";
          
          
       }
       echo "</div>";
       /* SIIII! */


$this->db->like('idalbum', '');
$this->db->from('album_photo');
$this->NroRegistros = $this->db->count_all_results();
$this->PagAnt=$this->PagAct-1;
$this->PagSig=$this->PagAct+1;
$this->PagUlt=$this->NroRegistros/$this->RegistrosAMostrar;

//verificamos residuo para ver si llevará decimales
$this->Res=$this->NroRegistros%$this->RegistrosAMostrar;
// si hay residuo usamos funcion floor para que me
// devuelva la parte entera, SIN REDONDEAR, y le sumamos
// una unidad para obtener la ultima pagina
if($this->Res>0) $this->PagUlt=floor($this->PagUlt)+1;

//desplazamiento
echo $this->NroRegistros.'este<br />';
echo "&lt;a onclick=\"get('1')\"&gt;Primero</a> ";
if($this->PagAct>1) echo "&lt;a onclick=\"get('$this-&gt;PagAnt')\">Anterior</a> ";
echo "<strong>Pagina ".$this->PagAct."/".$this->PagUlt."</strong>";
if($this->PagAct<$this->PagUlt)  echo " &lt;a onclick=\"get('$this-&gt;PagSig')\">Siguiente</a> ";
echo "&lt;a onclick=\"get('$this-&gt;PagUlt')\">Ultimo</a>";
/* SIIIII FIN */

        
        
        
        
        
    }
#5

[eluser]MMCCQQ[/eluser]
[quote author="Nick Husher" date="1202788188"]You will need to collect information on how many photographs you have. There's a way of doing a count of the number of records in the table without actually calling count, and I seem to remember a few threads on that topic on this forum. You'll then need to hand that information either to your view when the page loads, or to your javascript widget as you change the page. At the moment, you're sending just the code for the image, but you could also pass along the pagination information as well:
Code:
<div id='thumb_wrap'>
<div id='thumb'><img src='http://beta.importzona.com/IMAGE_HREF'></div>;
</div>
&lt;a href="#" onclick="get('PAGE_NUMBER - 1')"&gt; << Previous </a>
CURRENT_PAGE of ROW_COUNT
&lt;a href="#" onclick="get('PAGE_NUMBER + 1')"&gt; Next >></a>

You need to replace the capitalized keywords with your calculated values, of course. Also, you might want to think about switching to some more-unobtrusive javascript. Onclicks are so 1999. Wink[/quote]

can you tell me how can i get Pagination Links?
#6

[eluser]Pascal Kriete[/eluser]
Why don't you try to first do pagination using the native CI library. Then once you get that working, you can hijack it with javascript. It's very difficult to debug php and javascript together.

Starting with pure php also has the advantage of encouraging unobtrusive javascript. You will not have to change a single thing in your html body (assuming everything has an id) once you start to write your javascript.

Let us now how it goes Smile.
#7

[eluser]MMCCQQ[/eluser]
how can i apply Pagination Library?

i dont know :S
#8

[eluser]tunelko[/eluser]
maybe the method create_lnks() ?

You must start reading Wink




Theme © iAndrew 2016 - Forum software by © MyBB