I'm working on a small web app that uses drag and drop to add users to projects for management purposes. It's hard to describe the problem without showing the relevant code, so I'll start with that first:
<div id="primary">
<?php
foreach($jobs as $job):
?>
<div id="jobdiv-<?php echo $job->id; ?>">
<h3><?php echo $job->name; ?></h3>
<div id="ajaxdiv-<?php echo $job->id; ?>">
Loading users...
</div>
</div>
<?php
endforeach;
?>
</div>
<div id="secondary">
<?php
foreach($users as $row):
?>
<p id="p-<?php echo $row->id; ?>" style="width:0;" class="user" alt="<?php echo $row->id; ?>"><?php echo $row->name; ?></p>
<?php
endforeach;
?>
</div>
<?php
foreach($jobs as $job):
?>
Droppables.add('jobdiv-<?php echo $job->id; ?>', {
accept: 'user',
onDrop: function(element) {
$('jobdiv-<?php echo $job->id; ?>').highlight();
new Ajax.Updater('add_user', '/index.php/user/addUserToJob/' + element.alt + '/<?php echo $job->id; ?>', { method: 'get' });
new Ajax.Updater('ajaxdiv-<?php echo $job->id; ?>', '/index.php/user/jobDisplay/<?php echo $job->id; ?>', { method: 'get' });
}
});
<?php
endforeach;
?>
So the line new Ajax.Updater('add_user', '/index.php/user/addUserToJob/' + element.alt + '/<?php echo $job->id; ?>', { method: 'get' });
works how I'd expect for the most part but element.alt
is returned as "undefined." Can anyone see a reason why it would do this? Or maybe a different way? If I wasn't clear enough with my question please ask me to clarify.
Thanks!