<heidi.anselstetter@consultingteam.de> wrote:
> Hi,
>
> My idea is to have a list of database data listed in a table, one row
> per member data details.
> Each member has a link to open a popup (I am using a basic modal
> jquery script). In this popup I would like to have a comment field to
> add comments regarding the selected client.
>
> I am not sure how to do that.
> How can I call the popup with the comment field, which is outsourced
> in a element, and parse the member id to it?
>
> Guess I have a table like
> ...
> <td>memberid 1</td><td>echo $this->Html->link(__('leave a comment',
> true),?></td>
> </tr><tr>
> <td>memberid 2</td><td>echo $this->Html->link(__('leave a comment',
> true),?></td>
> </tr><tr>
> <td>memberid 3</td><td>echo $this->Html->link(__('leave a comment',
> true),?></td>
>
> My element looks like
> <div id="popup">
> <?php echo $this->Ajax->Form('comment', 'post', array('url' =>
> array('action' => 'comment'))); ?>
> <input type="hidden" id="memberID" value="????">
> ...
> <td><textarea cols="10" rows="5" name="comment"></textarea></td>
> ....
> <?php echo $this->Ajax->Form->end(); ?>
> </div>
>
I think the best way to handle this is to pass the ID through the
click handler that opens the pop-up, as it's the routine that connects
a Member record row with the form.
BTW, I recommend you use buttons instead of links for this as they're
better suited to the job.
http://particletree.com/features/rediscovering-the-button-element/
Essentially, what you want to do is assign a unique id attribute to
some tag (or rel if it's the right type for that) in each row that's
based on the Member.id. This could be the tr, the td, the a, input, or
button. Because IDs can't begin with a number you'll need to supply
some prefix and then parse out the id.
<button id="member_437">...</button> ...
<button id="member_438">...</button> ...
JS:
var member_id = $(this).attr('id').replace(/member_/, '');
The above is for when the id has been given to the button or link
itself. If you apply it instead to the table row (perhaps you have
several buttons per row which handle various tasks) you'd do something
like:
var member_id = $(this).closest('tr').attr('id').replace(/member_/, '');
Once you have the id you can then apply it to the hidden form element.
$('#memberID', $('#popup')).val(member_id);
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment