Domanda

Sto usando CakePHP 2.0 e cercando di creare ajax paging che i cant nella documentazione ho letto che questo passaggio

$this->Paginator->options(
                          array('update'=>'#box',
                                'evalScripts' => true,
                                'before' => $this->Js->get('#loaderIDast')->effect('fadeIn', array('buffer' => false)),
                                'complete' => $this->Js->get('#loaderIDast')->effect('fadeOut', array('buffer' => false)),
                          ))

nella vista renderà paginaton aiuto per creare ajax collegamento che nel mio caso doesnt. Sto usando il motore jQuery qui.

a scavare i file di libreria che mi sono imbattuto in paginator sta utilizzando la funzione di evento che sta facendo questo

jQuery("#link-969794460").bind("click", function (event) {jQuery.ajax({beforeSend:function (XMLHttpRequest) {jQuery("#loaderIDast").fadeIn();}, complete:function (XMLHttpRequest, textStatus) {jQuery("#loaderIDast").fadeOut();}, dataType:"html", evalScripts:true, success:function (data, textStatus) {jQuery("#box").html(data);}, url:"\/admin\/user\/manage_user\/sort:User.name\/direction:asc"}); return false;});

e questo non è in qualche modo restituito in caso call.I non so perché qualcuno ha un'idea che cosa mi manca?

Saluti Himanshu Sharma.

È stato utile?

Soluzione

In realtà, ci sono ad esempio nel libro qui . Cercare la sezione Ajax impaginazione. Assicurati di seguire tutte le direzioni e che funzionerà.

È necessario:

  • Il componente RequestHandler da caricare nel controllore.
  • Il Helper Js da caricare nel controllore.
  • È necessario includere jQuery nella vista / layout.
  • E è necessario scrivere il buffer Js ($this->Js->writeBuffer()) nella vista / layout. E suggerirei mettere questo nella vista a meno che non si carica l'helper Js nel AppController perché altrimenti non sarà definito $this->Js.

L'esempio nel libro utilizza jQuery e lavora.

Altri suggerimenti

Si prega di non dimenticare di aggiungere i $ this->> Paginator- numeri () dopo aver detto impaginazione di supporto che si desidera un collegamento javascript invece del semplice HTML

    <?php
$this->Paginator->options(array(
        'update' => '#content',
        'evalScripts' => true,
        'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
        'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)),
    ));
    ?>
    <?php echo $this->Paginator->numbers();?>

Ho avuto lo stesso problema, ma nel mio caso l'id del tag div nel file di layout sbagliavo. Dovrebbe essere "contenuto".

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top