[Proto-Scripty] Re: Selectively prevent onClick action ?
david wrote: Sorry, I needed some more test, i did not use traditionnal event model: I'm not sure I understood the code you sent. Where does process() get called? I've put together a simple version of what I'm trying to do. Code follows: html head titleEvent Propagation/title script src=prototype.js type=text/javascript/script script type=text/javascript function showPopup() { alert('popup'); } function setRow() { alert('row'); } /script /head body div id='hoverdiv' style='display:none; position:absolute; top: 0; left:0;'/div div id='results' table border='1' thead tr thColumn 1/th thColumn 2/th thColumn 3/th /tr /thead tbody tr onclick='showPopup(this, 1)' tdRow 1-1/td tdRow 1-2/td td div id='row-1' a href='#' onclick='setRow()'Row 1-3/a /div /td /tr /tbody /table /div /body /html What I'm looking to do is fire showPopup() on a click inside the tr. However, if the a href is clicked instead, I want setRow() to fire, but not showPopup. Both of those functions will have Ajax.Updater calls in them, but I left them out for simplicity as I don't believe they have any bearing on this problem. I did some digging on stopPropagation and it looks like you can only use that on event handlers? How do I obtain a reference to the event handler? Thanks for your help thus far! -- david -- --- Jason Frisvold xenopha...@gmail.com --- I love deadlines. I like the whooshing sound they make as they fly by. - Douglas Adams --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Selectively prevent onClick action ?
look at Event.stop(event) ... that will stop it bubbling up the DOM but you need the event passed to the function HTH ALex - Original Message - From: Jason Frisvold xenopha...@gmail.com To: prototype-scriptaculous@googlegroups.com Sent: Friday, February 20, 2009 1:58 PM Subject: [Proto-Scripty] Re: Selectively prevent onClick action ? david wrote: Sorry, I needed some more test, i did not use traditionnal event model: I'm not sure I understood the code you sent. Where does process() get called? I've put together a simple version of what I'm trying to do. Code follows: html head titleEvent Propagation/title script src=prototype.js type=text/javascript/script script type=text/javascript function showPopup() { alert('popup'); } function setRow() { alert('row'); } /script /head body div id='hoverdiv' style='display:none; position:absolute; top: 0; left:0;'/div div id='results' table border='1' thead tr thColumn 1/th thColumn 2/th thColumn 3/th /tr /thead tbody tr onclick='showPopup(this, 1)' tdRow 1-1/td tdRow 1-2/td td div id='row-1' a href='#' onclick='setRow()'Row 1-3/a /div /td /tr /tbody /table /div /body /html What I'm looking to do is fire showPopup() on a click inside the tr. However, if the a href is clicked instead, I want setRow() to fire, but not showPopup. Both of those functions will have Ajax.Updater calls in them, but I left them out for simplicity as I don't believe they have any bearing on this problem. I did some digging on stopPropagation and it looks like you can only use that on event handlers? How do I obtain a reference to the event handler? Thanks for your help thus far! -- david -- --- Jason Frisvold xenopha...@gmail.com --- I love deadlines. I like the whooshing sound they make as they fly by. - Douglas Adams --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Selectively prevent onClick action ?
Alex Mcauley wrote: look at Event.stop(event) ... that will stop it bubbling up the DOM Excellent, thanks. but you need the event passed to the function That was the bit I was having a problem with, but I figured it out. I can pass the event itself via the function call. a href='#' onclick='setRow(event)'Row 1-3/a Once I had that, finishing the rest was easy.. HTH ALex Thanks for the help all! -- --- Jason Frisvold xenopha...@gmail.com --- I love deadlines. I like the whooshing sound they make as they fly by. - Douglas Adams --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Selectively prevent onClick action ?
Hi Jason, I don't think it's possible, because you use Event inline, and you can't control the event bubbling or propagation. If you register the event with or without prototype but programmatically with the traditionnal model, you could use the event.stopPropagation function or for IE the window.event.cancelBubble. Go to this link, everything is explain: first part: http://www.quirksmode.org/js/introevents.html second part: http://www.quirksmode.org/js/events_order.html and if you want to switch to a registration with prototype, go to: http://prototypejs.org/api/event -- david On 16 fév, 22:50, Jason Frisvold xenopha...@gmail.com wrote: I'm not sure if this calls for a redesign, or if this is valid behavior. I have a table with an onClick action on the tr tags. Normally, I want this behavior to fire every time a row is clicked with one exception. Within the tr is an a href that triggers a different behavior on a click. At the moment, both behaviors fire simultaneously, both completing as they should. What I'd like to do is prevent the tr onclick from firing when I've specifically clicked on the a href. Is this possible? The code looks like this (using PHP smarty) : tr onclick='showPopup(this, {$row.id});' td{$row.vendor}/td td div id='trust-{$row.id}' img src='images/icon_thumbsup.gif' style='border: none' onclick='setTrust(1, {$row.id}, {$row.trust});' / {$row.trust} img src='images/icon_thumbsdown.gif' style='border: none' onclick='setTrust(0, {$row.id}, {$row.trust});' / /div /td /tr Both onclick functions are essentially ajax.updater functions with some scriptaculous effects thrown in for good measure. Thanks, -- --- Jason Frisvold xenopha...@gmail.com --- I love deadlines. I like the whooshing sound they make as they fly by. - Douglas Adams --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Selectively prevent onClick action ?
Sorry, I needed some more test, i did not use traditionnal event model: try this: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; lang=en xml:lang=en head titleo0O TEST O0o/title /head body div id=contener style=width:100px;height:100px;background- color:blue onClick=alert('parent'); div id=child style=width:50px;height:50px;background- color:red/div /div script var stop='ok'; function process(e){ if (stop=='ok') e.stopPropagation(); alert('event on child launch but stop propagation for parent'); } document.getElementById('child').onclick=process; /script /script /body /html -- david On 16 fév, 23:46, david david.brill...@gmail.com wrote: Hi Jason, I don't think it's possible, because you use Event inline, and you can't control the event bubbling or propagation. If you register the event with or without prototype but programmatically with the traditionnal model, you could use the event.stopPropagation function or for IE the window.event.cancelBubble. Go to this link, everything is explain: first part: http://www.quirksmode.org/js/introevents.html second part: http://www.quirksmode.org/js/events_order.html and if you want to switch to a registration with prototype, go to:http://prototypejs.org/api/event -- david On 16 fév, 22:50, Jason Frisvold xenopha...@gmail.com wrote: I'm not sure if this calls for a redesign, or if this is valid behavior. I have a table with an onClick action on the tr tags. Normally, I want this behavior to fire every time a row is clicked with one exception. Within the tr is an a href that triggers a different behavior on a click. At the moment, both behaviors fire simultaneously, both completing as they should. What I'd like to do is prevent the tr onclick from firing when I've specifically clicked on the a href. Is this possible? The code looks like this (using PHP smarty) : tr onclick='showPopup(this, {$row.id});' td{$row.vendor}/td td div id='trust-{$row.id}' img src='images/icon_thumbsup.gif' style='border: none' onclick='setTrust(1, {$row.id}, {$row.trust});' / {$row.trust} img src='images/icon_thumbsdown.gif' style='border: none' onclick='setTrust(0, {$row.id}, {$row.trust});' / /div /td /tr Both onclick functions are essentially ajax.updater functions with some scriptaculous effects thrown in for good measure. Thanks, -- --- Jason Frisvold xenopha...@gmail.com --- I love deadlines. I like the whooshing sound they make as they fly by. - Douglas Adams --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---