Thursday, February 23, 2012

Multiple modal box on one page, cakePHP-jQuery

November 6, 2010 by Ayo Akinyemi · Leave a Comment 

You must have installed jquery, called ajax helper in your controller and also call jquery in your layout

Dynamically calling multiple modal box on a single page:

In your view page,
<?php echo $html->scriptStart() ?>
$(function() {
$(‘a#userinfoID’).click(function() {
var uid = $(this).attr(‘userinfo’);

$(‘#userdialog’ + uid).dialog(‘open’);
return false;
});
});
<?php echo $html->scriptEnd() ?>

<?php echo $this->Html->link(__($user['User']['user_name'], true), array(‘action’ => ‘view’,     $user['User']['id']), array(‘id’=>’userinfoID’,'userinfo’=> $user['User']['id'])); ?>

<div id=”<?php echo $userdialog; ?>”>
<?php echo $user['User']['id']; ?>
</div>

I skipped the foreach loop. drop a comment if you have a question.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

You must be logged in to post a comment.