François Beausoleil
2005-Sep-14 11:13 UTC
[Rails-spinoffs] How to drag/drop visitable anchors ?
Hi ! I have the following: <li id="photo_<%= @photo.id %>" class="photo"> <%= link_to(image_tag(url_for_file_column(:photo, :picture)), {:action => ''photo'', :id => @photo}, {:title => @photo.description}) %> </li> <script type="text/javascript" language="JavaScript"><!-- Behaviour.register({ ''#gallery li.photo'': function(el) { new Draggable(el, {revert: true}); }, ''#gallery li.target'': function(el) { Droppables.add(el, {accept: ''photo'', hoverclass: ''accept''}); }, }); //--></script> You see I have an LI with an A element inside. The A links to a full-size view of the thumbnail. I want to be able to drag/drop the picture, but at the same time, if the user clicks the link, the browser should visit the page... Is there anyway I can do that without resorting to drag anchors ? Right now, what happens is that after the drag, the browser visits the A''s href''ed page. Thanks ! Fran?ois
François Beausoleil
2005-Sep-14 11:16 UTC
[Rails-spinoffs] How to drag/drop visitable anchors ?
Forgot to say I''m on FireFox 1.0.6, and FireFox is the target platform (no IE - Yea!) Thanks, Fran?ois
Renato Formato
2005-Sep-14 11:40 UTC
[Rails-spinoffs] How to drag/drop visitable anchors ?
Fran?ois Beausoleil ha scritto:> Hi ! > > I have the following: > <li id="photo_<%= @photo.id %>" class="photo"> > <%= link_to(image_tag(url_for_file_column(:photo, :picture)), > {:action => ''photo'', :id => @photo}, > {:title => @photo.description}) %> > </li> > > <script type="text/javascript" language="JavaScript"><!-- > Behaviour.register({ > ''#gallery li.photo'': function(el) { > new Draggable(el, {revert: true}); > }, > > ''#gallery li.target'': function(el) { > Droppables.add(el, {accept: ''photo'', hoverclass: ''accept''}); > }, > }); > //--></script> > > You see I have an LI with an A element inside. The A links to a > full-size view of the thumbnail. I want to be able to drag/drop the > picture, but at the same time, if the user clicks the link, the > browser should visit the page... > > Is there anyway I can do that without resorting to drag anchors ? > > Right now, what happens is that after the drag, the browser visits the > A''s href''ed page. > > Thanks ! > Fran?ois > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >Hi, I''ve managed to stop the onclick event by setting an onclick event handler to query a property I added to the Draggable object to track if dragging was started. The handler executes this code: function stopClick(event) { if (!event) event = window.event var drag=this.parentNode.drag; //retrieve the Draggable object if(drag.justdragged) {Event.stop(event);drag.justdragged=false;} } where drag is the Draggable object and justdragged is the new property to track if dragging was started. Now, as I just reviewed my code, I think you can query for the property "dragging" without setting it back to false (not tested): function stopClick(event) { if (!event) event = window.event var drag=this.parentNode.drag; //retrieve the Draggable object if(drag.dragging) {Event.stop(event);} } Ciao Renato
François Beausoleil
2005-Sep-14 14:56 UTC
[Rails-spinoffs] How to drag/drop visitable anchors ?
Hi ! Renato Formato said the following on 2005-09-14 11:47:> Hi, I''ve managed to stop the onclick event by setting an onclick event > handler to query a property I added to the Draggable object to track if > dragging was started. > The handler executes this code: > > function stopClick(event) { > if (!event) event = window.event > var drag=this.parentNode.drag; //retrieve the Draggable object > if(drag.justdragged) {Event.stop(event);drag.justdragged=false;} > } > > where drag is the Draggable object and justdragged is the new property > to track if dragging was started.Thanks, but it doesn''t seem to work for me. Besides, if I look at Draggable''s code, I can see this: startDrag: function(event) { if(Event.isLeftClick(event)) { this.active = true; var style = this.element.style; // deleted stuff Event.stop(event); } }, You see, the DnD library already stops propagation of the event... Also, Draggable.active seems to serve the same purpose as your justdragged property. There must be something I''m not understanding here. Thanks, Fran?ois
Francois, Did you ever resolve this issue? Thanks, Shane On 9/14/05, François Beausoleil <fbeausoleil-IQIa899fVSs@public.gmane.org> wrote:> > Hi ! > > Renato Formato said the following on 2005-09-14 11:47: > > Hi, I''ve managed to stop the onclick event by setting an onclick event > > handler to query a property I added to the Draggable object to track if > > dragging was started. > > The handler executes this code: > > > > function stopClick(event) { > > if (!event) event = window.event > > var drag=this.parentNode.drag; //retrieve the Draggable object > > if(drag.justdragged) {Event.stop(event);drag.justdragged=false;} > > } > > > > where drag is the Draggable object and justdragged is the new property > > to track if dragging was started. > > Thanks, but it doesn''t seem to work for me. Besides, if I look at > Draggable''s code, I can see this: > startDrag: function(event) { > if(Event.isLeftClick(event)) { > this.active = true; > > var style = this.element.style; > // deleted stuff > > Event.stop(event); > } > }, > > You see, the DnD library already stops propagation of the event... > Also, Draggable.active seems to serve the same purpose as your > justdragged property. > > There must be something I''m not understanding here. > > Thanks, > François > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs