User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,923 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,725 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 219 | Replies: 1
Reply
Join Date: Sep 2007
Location: Cincinnati, OH USA
Posts: 10
Reputation: sethbaur is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
sethbaur sethbaur is offline Offline
Newbie Poster

Help needed with Scriptaculous/Prototype

  #1  
12 Days Ago
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:

  1. <div id="primary">
  2. <?php
  3. foreach($jobs as $job):
  4. ?>
  5. <div id="jobdiv-<?php echo $job-> id; ?>">
  6. <h3> <?php echo $job-> name; ?></h3>
  7. <div id="ajaxdiv-<?php echo $job->id; ?>">
  8. Loading users...
  9. </div>
  10. </div>
  11. <?php
  12. endforeach;
  13. ?>
  14. </div>
  15. <div id="secondary">
  16. <?php
  17. foreach($users as $row):
  18. ?>
  19. <p id="p-<?php echo $row-> id; ?>" style="width:0;" class="user" alt="<?php echo $row-> id; ?>"><?php echo $row-> name; ?></p>
  20. <?php
  21. endforeach;
  22. ?>
  23. </div>

  1. <?php
  2. foreach($jobs as $job):
  3. ?>
  4. Droppables.add('jobdiv-<?php echo $job->id; ?>', {
  5. accept: 'user',
  6. onDrop: function(element) {
  7. $('jobdiv-<?php echo $job->id; ?>').highlight();
  8. new Ajax.Updater('add_user', '/index.php/user/addUserToJob/' + element.alt + '/<?php echo $job->id; ?>', { method: 'get' });
  9. new Ajax.Updater('ajaxdiv-<?php echo $job->id; ?>', '/index.php/user/jobDisplay/<?php echo $job->id; ?>', { method: 'get' });
  10. }
  11. });
  12. <?php
  13. endforeach;
  14. ?>

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!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2008
Posts: 236
Reputation: langsor is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 20
langsor langsor is offline Offline
Posting Whiz in Training

Re: Help needed with Scriptaculous/Prototype

  #2  
12 Days Ago
Scriptaculous -- never use the stuff, I hear it's habit forming and gives you cancer ...

But seriously, I never use code I don't understand, thus code I didn't write myself ... but here's a couple ideas.

Try testing the element object passed into the function to see what data it displays ... maybe this will clear up what's going on.
alert( typeof element );

// or

var txt = '';
for ( i in element ) {
  txt += element + ' :: ' + element[i] + '\n';
}
alert( txt );

If element is an object or function and has an alt property then I have no clue why it's not working. If element has properties but not an alt property defined (populated) then the hangup is on the server end of things, probably in the PHP that the Ajax is talking to.

Good luck
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 8:16 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC