chris-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org
2007-Jun-28 21:00 UTC
Droppable onHover fires on page load, not on hover
Hi all, first post. I have a simple set of drag/drops that I''m trying to use in FF. Unfortunately on page load all of the droppables on the page fire simultaneously and then won''t respond to any futher attempts to drop anything on them. Firebug isn''t showing any errors and I''m completely stumped... Any ideas of where to look? using: Droppables.add(divIdName, {accept: ''prospect'', onHover: showConsultantSchedule(keyVar)}); where divIdName is the var to the div name and keyVar is the ID that I need to send to the DB server and prospect is the class of the draggables I''m also using handles on the drags that match the div id that they are assigned to (already tried changing their name to no avail...) Thanks for any insight! Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
There are variations on this question a couple of times per week, it seems. It comes from a lack of understanding of function references, and how to use them. Given the code below, it is clear you are assigning the *result* of showConsultantSchedule (i.e. the return value after you call it), rather than a reference to it. That''s the difference between onHover: someFunc() and onHover: someFunc From peeking at the Scriptaculous code, it seems the "onHover" callback passes three parameters, as follows: function(element, dropon, overlap) ... so you could rewrite your showConsultantSchedule() function to accept these parameters. TAG On Jun 28, 2007, at 3:00 PM, chris-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org wrote:> > Hi all, first post. I have a simple set of drag/drops that I''m trying > to use in FF. Unfortunately on page load all of the droppables on the > page fire simultaneously and then won''t respond to any futher attempts > to drop anything on them. Firebug isn''t showing any errors and I''m > completely stumped... Any ideas of where to look? > > using: Droppables.add(divIdName, {accept: ''prospect'', onHover: > showConsultantSchedule(keyVar)}); > where divIdName is the var to the div name > and keyVar is the ID that I need to send to the DB server > and prospect is the class of the draggables > > I''m also using handles on the drags that match the div id that they > are assigned to (already tried changing their name to no avail...) > > Thanks for any insight! > > Chris > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
chris-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org
2007-Jun-28 21:42 UTC
Re: Droppable onHover fires on page load, not on hover
That worked, thanks for the quick lesson. The next problem is that now when I hover over the drop, the event fires 10 times (the number of items in the prospect class total) instead of just once. Changed the code to: Droppables.add(divIdName, {accept: ''prospect'', onHover: function() {showConsultantSchedule(keyVar)} }); Thanks! Chris On Jun 28, 4:25 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> There are variations on this question a couple of times per week, it > seems. It comes from a lack of understanding of function references, > and how to use them. > > Given the code below, it is clear you are assigning the *result* of > showConsultantSchedule (i.e. the return value after you call it), > rather than a reference to it. > > That''s the difference between > onHover: someFunc() > > and > onHover: someFunc > > From peeking at the Scriptaculous code, it seems the "onHover" > callback passes three parameters, as follows: > function(element, dropon, overlap) > > ... so you could rewrite your showConsultantSchedule() function to > accept these parameters. > > TAG > > On Jun 28, 2007, at 3:00 PM, c...-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org wrote: > > > > > > > Hi all, first post. I have a simple set of drag/drops that I''m trying > > to use in FF. Unfortunately on page load all of the droppables on the > > page fire simultaneously and then won''t respond to any futher attempts > > to drop anything on them. Firebug isn''t showing any errors and I''m > > completely stumped... Any ideas of where to look? > > > using: Droppables.add(divIdName, {accept: ''prospect'', onHover: > > showConsultantSchedule(keyVar)}); > > where divIdName is the var to the div name > > and keyVar is the ID that I need to send to the DB server > > and prospect is the class of the draggables > > > I''m also using handles on the drags that match the div id that they > > are assigned to (already tried changing their name to no avail...) > > > Thanks for any insight! > > > Chris- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
chris-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org
2007-Jun-28 22:12 UTC
Re: Droppable onHover fires on page load, not on hover
Actually, I did some experimenting and it is not actually firing the event 10 times every time, it seems to be tied to the number of pixels into the droppable that I go. If I hold still, it will stop firing but fire the moment I move the draggable, the exact number of times for every pixel that I move it. I tried the "greedy" option but it looks like it only is for layered droppables and had no effect. Chris On Jun 28, 4:42 pm, "c...-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org" <c...-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org> wrote:> That worked, thanks for the quick lesson. The next problem is that > now when I hover over the drop, the event fires 10 times (the number > of items in the prospect class total) instead of just once. > > Changed the code to: > > Droppables.add(divIdName, {accept: ''prospect'', onHover: function() > {showConsultantSchedule(keyVar)} }); > > Thanks! > > Chris > > On Jun 28, 4:25 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote: > > > > > There are variations on this question a couple of times per week, it > > seems. It comes from a lack of understanding of function references, > > and how to use them. > > > Given the code below, it is clear you are assigning the *result* of > > showConsultantSchedule (i.e. the return value after you call it), > > rather than a reference to it. > > > That''s the difference between > > onHover: someFunc() > > > and > > onHover: someFunc > > > From peeking at the Scriptaculous code, it seems the "onHover" > > callback passes three parameters, as follows: > > function(element, dropon, overlap) > > > ... so you could rewrite your showConsultantSchedule() function to > > accept these parameters. > > > TAG > > > On Jun 28, 2007, at 3:00 PM, c...-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org wrote: > > > > Hi all, first post. I have a simple set of drag/drops that I''m trying > > > to use in FF. Unfortunately on page load all of the droppables on the > > > page fire simultaneously and then won''t respond to any futher attempts > > > to drop anything on them. Firebug isn''t showing any errors and I''m > > > completely stumped... Any ideas of where to look? > > > > using: Droppables.add(divIdName, {accept: ''prospect'', onHover: > > > showConsultantSchedule(keyVar)}); > > > where divIdName is the var to the div name > > > and keyVar is the ID that I need to send to the DB server > > > and prospect is the class of the draggables > > > > I''m also using handles on the drags that match the div id that they > > > are assigned to (already tried changing their name to no avail...) > > > > Thanks for any insight! > > > > Chris- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Two questions that may help someone better address your issue: 1. What version of Prototype/Scriptaculous are you using? 2. Can you post your code somewhere? TAG On Jun 28, 2007, at 4:12 PM, chris-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org wrote:> > Actually, I did some experimenting and it is not actually firing the > event 10 times every time, it seems to be tied to the number of pixels > into the droppable that I go. If I hold still, it will stop firing > but fire the moment I move the draggable, the exact number of times > for every pixel that I move it. I tried the "greedy" option but it > looks like it only is for layered droppables and had no effect. > > Chris > > On Jun 28, 4:42 pm, "c...-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org" <c...-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org> wrote: >> That worked, thanks for the quick lesson. The next problem is that >> now when I hover over the drop, the event fires 10 times (the number >> of items in the prospect class total) instead of just once. >> >> Changed the code to: >> >> Droppables.add(divIdName, {accept: ''prospect'', onHover: function() >> {showConsultantSchedule(keyVar)} }); >> >> Thanks! >> >> Chris--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
chris-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org
2007-Jun-29 14:27 UTC
Re: Droppable onHover fires on page load, not on hover
Here''s the html portion: <div id = ''calendar''> <script>new Ajax.Request(''/cgi-bin/gen3.cgi?p=Generate_Calendar'', { method:''get'', onSuccess: function(transport){ var response transport.responseText || "No Response from Server"; var p_temp = new Array(); p_temp = response.split('' ''); p_temp.each( function(p_key) { addCalendarElement(p_key); }); build_action_area(); }, onFailure: function(){ alert(''Lost Connection.'') } }); </script> </div> And the relevant JS: <script language="javascript"> function addCalendarElement(keyVar) { var ni = document.getElementById(''calendar''); var newdiv = document.createElement(''div''); var divIdName = ''Con''+keyVar; newdiv.setAttribute(''id'',divIdName); newdiv.setAttribute(''class'',''consultant''); newdiv.innerHTML = ''<img src="/gen3_images/indicator.gif" alt="Loading..." />''; ni.appendChild(newdiv); Droppables.add(divIdName, {accept: ''prospect'', onHover: function() {showConsultantSchedule(keyVar)} }); new Ajax.Updater(divIdName, ''/cgi-bin/gen3.cgi? p=Get_Consultant_Info&consultant=''+keyVar, { method:''get''}); } function showConsultantSchedule(cons) { new Ajax.Updater(''schedule'', ''/cgi-bin/gen3.cgi? p=Show_Consultant_Schedule&consultant=''+cons, { method:''get''}); } </script> I know this is simple code and not very elegant yet, but I''m just building a prototype of the program to show the usefulness of such a setup over our current system. Any help would be appreciated. I''ve tried this code on both the 1.7.0 and 1.7.1b3 scripts and it still fired constantly when there is movement in the drop zone. On Jun 28, 5:23 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> Two questions that may help someone better address your issue: > > 1. What version of Prototype/Scriptaculous are you using? > > 2. Can you post your code somewhere? > > TAG > > On Jun 28, 2007, at 4:12 PM, c...-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org wrote: > > > > > > > Actually, I did some experimenting and it is not actually firing the > > event 10 times every time, it seems to be tied to the number of pixels > > into the droppable that I go. If I hold still, it will stop firing > > but fire the moment I move the draggable, the exact number of times > > for every pixel that I move it. I tried the "greedy" option but it > > looks like it only is for layered droppables and had no effect. > > > Chris > > > On Jun 28, 4:42 pm, "c...-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org" <c...-Rr9DA/eDl4tzbRFIqnYvSA@public.gmane.org> wrote: > >> That worked, thanks for the quick lesson. The next problem is that > >> now when I hover over the drop, the event fires 10 times (the number > >> of items in the prospect class total) instead of just once. > > >> Changed the code to: > > >> Droppables.add(divIdName, {accept: ''prospect'', onHover: function() > >> {showConsultantSchedule(keyVar)} }); > > >> Thanks! > > >> Chris- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- reloading fragments of pages
- question about Sortables
- onHover: can u explain me this function ?
- sortable - after complete dropping element want to send ajax reqeust with id of elements: draggable and droppable
- Setting Ajax.Updater update target to alternate window?