Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
Passing a value based on button click in CakePHP2

I have a list of objects generated via the Elements folder in my CakePHP project.

I'm trying to implement a detail button where when the button is clicked, a new component appears with the specified details, where the component is used by all objects.

index.ctp where the list of objects will be displayed, in addition to a hidden details component

object.ctp element that has basic information of the object and a "details" button that is rendered by index.ctp multiple times with value object being passed into it.

// index.ctp
echo $this->element(
    'details',
    array(
         'object' => $object
    )
);

I have a jQuery function in index.ctp that allows me to retrieve the data-id value I set in the object.ctp file that logs the appropriate object ID.

// index.ctp
$(document).on("click", ".detail-button", function(e) {
    slider.slideReveal("show", function() {});
    var $button = $(this);
    var object_id = $(this).data('id');
    console.log(object_id);
});

How do I go about passing the appropriate $object value in $this->element(...) based on which object component is clicked?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda