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?