Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!