Re: Caka 2.x - Ajax Paging Troubles - Duplicate DOM Elements
In your view, you must set the element to #content instead of content2
$this->Paginator->options(array(
'update' => '#content',
'update' => '#content',
Hope this helps,
Luciano
On Friday, January 4, 2013 11:10:54 AM UTC-2, rod...@zetenta.com wrote:
-- On Friday, January 4, 2013 11:10:54 AM UTC-2, rod...@zetenta.com wrote:
Hi
First at all sorry about my english, it's really awful.
Now the question, I'm trying configure a simple pagination via ajax.
First time, page loads ok, whith the item list.
At first all seems OK, but when I check my html code, Ajax append a new element at DOM.
I go to Copy & Paste my code, I will appreciate a lot if someone can help me
Controller
MenusController.php
public function index() {
$this->paginate = array(
'limit' => 10,
'order' => array(
'Menu.id' => 'asc'
)
);
$this->Menu->recursive = 0;
$menus = $this->paginate('Menu');
$this->set(compact('menus'));
}
View
index.ctp
<?php
$this->Paginator->options(array(
'update' => '#content2',
'before' => $this->Js->get("#loader")->effect('fadeIn', array('buffer' => false)),
'complete' => $this->Js->get("#loader")->effect('fadeOut', array('buffer' => false)),
));
?>
<?php echo $this->Html->image('loader.gif', array('class' => 'hide', 'id' => 'loader', 'style'=>'display:none')); ?>
<div id="content2">
<table cellspacing="0" cellpadding="0" id="">
<?php
$tableHeaders = $this->Html->tableHeaders(array(
$this->Paginator->sort('id', 'ID'),
$this->Paginator->sort('item', 'Item'),
__('Actions')
));
echo $tableHeaders;
$rows = array();
foreach ($menus as $menu){
$rows[] = array(
$menu['Menu']['id'],
$this->Html->link($menu['Menu']['item'], array('action' => 'view', $menu['Menu']['id'])),
$this->Html->link(__('Editar'), array('action' => 'iu', $menu['Menu']['id'])),
);
}
echo $this->Html->tableCells($rows);
?>
</table>
<div class="paging">
<?php
//echo $this->Paginator->numbers();
echo $this->Paginator->prev('Anterior', null, null, array('class' => 'disable'));
echo $this->Paginator->next('Proximo', null, null, array('class' => 'disable'));
?>
</div>
<?php echo $this->Js->writeBuffer(); ?>
</div>
<?php echo $this->element('menu') ?>
HTML - When Page Load First Time
<div id="content">
<img id="loader" class="hide" alt="" style="display:none" src="/img/loader.gif">
<div id="content2">
<table id="" cellspacing="0" cellpadding="0">
HTML - When I do Click in Ajax Links (next or prev)
<div id="content">
<img id="loader" class="hide" alt="" style="display: none;" src="/img/loader.gif">
<div id="content2">
<img id="loader" class="hide" alt="" style="display:none" src="/img/loader.gif">
<div id="content2">
<table id="" cellspacing="0" cellpadding="0">
Thanks in advance
Rodrigo
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home