Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: JavaScript 24-Hour Trainer
This is the forum to discuss the Wrox book JavaScript 24-Hour Trainer Jeremy McPeak; ISBN: 978-0-470-64783-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: JavaScript 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 24th, 2011, 10:22 PM
jwg jwg is offline
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 24 Drag and Drop

The program in the book doesn't work properly. I typed in all and couldn't find any mistakes and then finally check the downloaded code which also doesn't work properly. In fact you get some pretty funky behavior that I haven't yet figured out the why of. It works fine if you drag the navy box and them the green box alternately but if you try to drag and drop and then drag and drop either of the boxes twice (or more in a row) things go wrong in a quite interesting way. The box remains where it is and a semi-transparent box follow along with the mouse cursor and only when you let go does the solid box jump to the new position. Then sometimes the box is stuck to the mouse cursor as if the mouseup was missed and it is necessary to click again to get the box and the mouse separated. I'd love to hear from J. McPeak how to fix this, and how to explain what accounts for the semitransparent box.
Reply With Quote
  #2 (permalink)  
Old December 25th, 2011, 12:32 AM
jmcpeak's Avatar
Wrox Author
Points: 361, Level: 6
Points: 361, Level: 6 Points: 361, Level: 6 Points: 361, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 77
Thanks: 0
Thanked 12 Times in 12 Posts
Default

Howdy, jwg.

What operating system and browser are you using?

I've tested in IE9, Chrome 16, and Firefox 7. The only browser that gives me unexpected results is Firefox 7. From the looks of it, the browser's built-in drag-n-drop functionality kicks in and causes some issues with the script. I'll look into it in a few days.
Reply With Quote
  #3 (permalink)  
Old January 4th, 2012, 11:11 PM
jwg jwg is offline
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Drag and Drop Problem

Hi JMCPeak,

I'm wondering if you have figured out any fix or alternative way of programming drag and drop that works.
Reply With Quote
  #4 (permalink)  
Old January 14th, 2012, 10:33 PM
jwg jwg is offline
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Request for a response from J Mcpeak

Hi again,

It's been quite a while and you said you'd have an answer in a few days. I'm wondering if you are stumped or if you are going to say anything more about the fact that the drag and drop program in chapter 24 doesn't work in the current version of Firefox? Is this a bug in Firefox that should be reported? Is there a way to write a drag and drop script in JavaScript that would work in the current version?

I tried to contact you through your homepage but the contact page did not work. I kept getting a message that there was an error and to try again.

I did respond to you request for the version number of Firefox that I'm using. Here it is again: 9.01 is what it says under Help -> about Firefox.

JWG
Reply With Quote
  #5 (permalink)  
Old January 16th, 2012, 12:25 PM
jmcpeak's Avatar
Wrox Author
Points: 361, Level: 6
Points: 361, Level: 6 Points: 361, Level: 6 Points: 361, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 77
Thanks: 0
Thanked 12 Times in 12 Posts
Default

My apologies, jwg. Time slipped away from me.

The fix is rather easy; just modify the code handling the mousedown event in the mouseHandler() function to look like this:

Code:
case "mousedown":
    if (eSrc.className.indexOf("draggable") > -1) {
        dragObj.dragging = true;
        dragObj.setDragObj(eSrc, x, y);
        eventUtility.preventDefault(event);
    }
    break;
The only change is the call to the eventUtility.preventDefault() method. That should prevent Firefox's built-in drag-n-drop feature from kicking in.
Reply With Quote
The Following User Says Thank You to jmcpeak For This Useful Post:
informatik01 (July 10th, 2012)
  #6 (permalink)  
Old February 3rd, 2012, 11:37 PM
jwg jwg is offline
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks

Thanks for the fix.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Drag and drop davidkpham BOOK: Beginning JavaScript and CSS Development with jQuery 6 July 12th, 2009 03:10 AM
Drag and Drop batott ASP.NET 2.0 Professional 3 April 26th, 2008 07:59 PM
Drag and drop vpinhao Beginning VB 6 0 September 11th, 2006 01:33 PM
Drag/Drop bmains Javascript 1 September 22nd, 2004 07:29 PM
Drag and drop Clive Astley Access 2 August 15th, 2003 12:11 PM



All times are GMT -4. The time now is 05:16 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.