[Proto-Scripty] Re: replace an anchor around a tablecell
Sorry for my lack of imagination here folks and thanks for the code example Walter. There's some tricky and interesting prototype code in your reply. Sometimes you just need a fresh set of eyes and a bit of humility. Thanks Everyone, Josh Robinson On Sep 30, 9:22 am, Walter Lee Davis <[EMAIL PROTECTED]> wrote: > If you can put the A inside the TD, like the W3 would prefer, then > this is probably very very solveable. > > If you had this: > > I'm a Cell > > Then you could do something like this (further down the page, or > wrapped in a document listener): > > $$('a[rel~="lightbox"]').each(function(elm){ > var td = elm.up('td'); > td.observe('mouseover',function(){ > td.addClassName('over'); > }); > td.observe('mouseout',function(){ > td.removeClassName('over'); > }); > td.observe('click',function(evt){ > evt.stop(); > alert("Help! I've been clicked!"); > }); > elm.replace(elm.innerHTML); > > }); > > And that should (untested) get you a td that responds to hover and > click as if the entire thing was a link. > > I am supposing here (since you were wrapping a td with a link in your > HTML) that this is the behavior you want to simulate, and you can't > use the much simpler CSS method: > > td.lightbox a { > display: block; > height: whatever; > width: whatever; > margin: 0; > > } > > Click me click me > > Walter > > On Sep 30, 2008, at 9:00 AM, josher565 wrote: > > > > > The reason why I have an anchor around a td is because the client has > > specified to me they want to use one of these "lightbox" > > implementations. There's a bunch of unstandardized implementations out > > there, but they are quick and easy to use. For me, I'd prefer to use > > some form of prototype object that knew how to do the lightbox. > > Unfortunately, I don't have that leeway. So despite my quick and dirty > > example code, is there a quick and dirty way to do this. Code or > > comment is greatly appreciated. > > > Josh > > > On Sep 29, 5:11 pm, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: > >> Hi, > > >> There are several problems with that markup. 1. You use double > >> quotes > >> in your JavaScript alert when the attribute is wrapped in double > >> quotes. 2. You don't have a closing double quote on something (hard > >> to say what, given #1). 3. is not a valid child of . That's > >> off the top of my head, there may be other problems. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: replace an anchor around a tablecell
If you can put the A inside the TD, like the W3 would prefer, then this is probably very very solveable. If you had this: I'm a Cell Then you could do something like this (further down the page, or wrapped in a document listener): $$('a[rel~="lightbox"]').each(function(elm){ var td = elm.up('td'); td.observe('mouseover',function(){ td.addClassName('over'); }); td.observe('mouseout',function(){ td.removeClassName('over'); }); td.observe('click',function(evt){ evt.stop(); alert("Help! I've been clicked!"); }); elm.replace(elm.innerHTML); }); And that should (untested) get you a td that responds to hover and click as if the entire thing was a link. I am supposing here (since you were wrapping a td with a link in your HTML) that this is the behavior you want to simulate, and you can't use the much simpler CSS method: td.lightbox a { display: block; height: whatever; width: whatever; margin: 0; } Click me click me Walter On Sep 30, 2008, at 9:00 AM, josher565 wrote: > > The reason why I have an anchor around a td is because the client has > specified to me they want to use one of these "lightbox" > implementations. There's a bunch of unstandardized implementations out > there, but they are quick and easy to use. For me, I'd prefer to use > some form of prototype object that knew how to do the lightbox. > Unfortunately, I don't have that leeway. So despite my quick and dirty > example code, is there a quick and dirty way to do this. Code or > comment is greatly appreciated. > > Josh > > On Sep 29, 5:11 pm, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: >> Hi, >> >> There are several problems with that markup. 1. You use double >> quotes >> in your JavaScript alert when the attribute is wrapped in double >> quotes. 2. You don't have a closing double quote on something (hard >> to say what, given #1). 3. is not a valid child of . That's >> off the top of my head, there may be other problems. >> --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: replace an anchor around a tablecell
Hi, > The reason why I have an anchor around a td is because the client has > specified to me they want to use one of these "lightbox" > implementations. I'm not seeing why you need to put an anchor *around* the table cell to use lightbox. Echoing what Justin said: What's the real requirement, the real goal? Clearly they didn't tell you "Put an anchor around the table cell." If they did, you'll have to educate them. It's like someone telling a plumber to fit the drain pipe from the bathtub so it empties into the toilet. It might work after a fashion in some situations (although it's more likely to overflow the toilet), but it's clearly wrong and no plumber worth hiring would actually do it. -- T.J. Crowder tj / crowder software / com On Sep 30, 2:00 pm, josher565 <[EMAIL PROTECTED]> wrote: > The reason why I have an anchor around a td is because the client has > specified to me they want to use one of these "lightbox" > implementations. There's a bunch of unstandardized implementations out > there, but they are quick and easy to use. For me, I'd prefer to use > some form of prototype object that knew how to do the lightbox. > Unfortunately, I don't have that leeway. So despite my quick and dirty > example code, is there a quick and dirty way to do this. Code or > comment is greatly appreciated. > > Josh > > On Sep 29, 5:11 pm, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: > > > Hi, > > > There are several problems with that markup. 1. You use double quotes > > in your JavaScript alert when the attribute is wrapped in double > > quotes. 2. You don't have a closing double quote on something (hard > > to say what, given #1). 3. is not a valid child of . That's > > off the top of my head, there may be other problems. > > > The W3C validator may be useful:http://validator.w3.org/ > > > I don't understand the requirement as stated well enough to suggest > > something else. > > > FWIW, > > -- > > T.J. Crowder > > tj / crowder software / com > > > On Sep 29, 9:27 pm, josher565 <[EMAIL PROTECTED]> wrote: > > > > Here's some example code: > > > > > > > > > > > > > > > > > > > > clicked")">I'm a Cell!! > > > > > > > > > > > > > > > > in a separate ajax call, I'm looking to use the Element.replace > > > function to replace the anchor with the outerHTML of the innermost > > > cell (wrappedtd in my example). See below: > > > > function MrAjax() > > > { > > > Element.replace("killme", $("wrappedtd").outerHTML) > > > > } > > > > The requirements state that I must be using the anchor and I have no > > > other option. The anchor must be deleted by some means, leaving the > > > wrapped cell. Your attention is appreciated. > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: replace an anchor around a tablecell
The reason why I have an anchor around a td is because the client has specified to me they want to use one of these "lightbox" implementations. There's a bunch of unstandardized implementations out there, but they are quick and easy to use. For me, I'd prefer to use some form of prototype object that knew how to do the lightbox. Unfortunately, I don't have that leeway. So despite my quick and dirty example code, is there a quick and dirty way to do this. Code or comment is greatly appreciated. Josh On Sep 29, 5:11 pm, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: > Hi, > > There are several problems with that markup. 1. You use double quotes > in your JavaScript alert when the attribute is wrapped in double > quotes. 2. You don't have a closing double quote on something (hard > to say what, given #1). 3. is not a valid child of . That's > off the top of my head, there may be other problems. > > The W3C validator may be useful:http://validator.w3.org/ > > I don't understand the requirement as stated well enough to suggest > something else. > > FWIW, > -- > T.J. Crowder > tj / crowder software / com > > On Sep 29, 9:27 pm, josher565 <[EMAIL PROTECTED]> wrote: > > > Here's some example code: > > > > > > > > > > > > > clicked")">I'm a Cell!! > > > > > > > > > > > in a separate ajax call, I'm looking to use the Element.replace > > function to replace the anchor with the outerHTML of the innermost > > cell (wrappedtd in my example). See below: > > > function MrAjax() > > { > > Element.replace("killme", $("wrappedtd").outerHTML) > > > } > > > The requirements state that I must be using the anchor and I have no > > other option. The anchor must be deleted by some means, leaving the > > wrapped cell. Your attention is appreciated. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: replace an anchor around a tablecell
A structure like that is not valid markup and should be avoided as it can/will produce unexpected behavior. A TD cannot have an anchor as a parent and a TR cannot have an anchor as a direct descendent. Furthermore, outerHTML is a proprietary Microsoft method and is not supported in other browsers. What is the end goal of what you are trying to do here? Why do you say it is required to have an anchor around a TD and what is the purpose of removing the anchor after some click action happens? -justin --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: replace an anchor around a tablecell
Hi, There are several problems with that markup. 1. You use double quotes in your JavaScript alert when the attribute is wrapped in double quotes. 2. You don't have a closing double quote on something (hard to say what, given #1). 3. is not a valid child of . That's off the top of my head, there may be other problems. The W3C validator may be useful: http://validator.w3.org/ I don't understand the requirement as stated well enough to suggest something else. FWIW, -- T.J. Crowder tj / crowder software / com On Sep 29, 9:27 pm, josher565 <[EMAIL PROTECTED]> wrote: > Here's some example code: > > > > > > clicked")">I'm a Cell!! > > > > > > in a separate ajax call, I'm looking to use the Element.replace > function to replace the anchor with the outerHTML of the innermost > cell (wrappedtd in my example). See below: > > function MrAjax() > { > Element.replace("killme", $("wrappedtd").outerHTML) > > } > > The requirements state that I must be using the anchor and I have no > other option. The anchor must be deleted by some means, leaving the > wrapped cell. Your attention is appreciated. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---