The following fails in IE 6 & 7 in about 1 out of 4/5 goes:
function showAdjacentThumb(link, increment){
var thumbs = $$(''#photo_block div.thumbnail img'');
var caption = link.up().previous();
var image = caption.previousSibling;
.......
The following always works:
function showAdjacentThumb(link, increment){
var thumbs = $$(''#photo_block div.thumbnail img'');
var caption = $(link.parentNode.previousSibling);
var image = caption.previousSibling;
AFAICT there''s no particular rhyme or reason why the code fails some
times and not others. It just comes up with js Syntax Error. Doing a
try/catch and inspecting the link doesn''t show anything amiss.
Any thoughts as to how I might narrow down what''s causing the problem?
Cheers
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
-~----------~----~----~----~------~----~------~--~---
Element#previous could return
undefined if no previous sibling is found.
Try specifying element tag name:
var caption = link.up().previous(''caption''), image;
if (caption) {
...
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Sorry, wasn''t very clear. The line that was failing was:
var caption = link.up().previous();
whereas if it''s changed to
var caption = $(link.parentNode.previousSibling);
it always works (exactly same data sets).
I have a sneaky suspicion it may be that when it''s failing
it''s
because IE doesn''t consider link to be a Prototype Element, just a
vanilla HTMLElement. Why, I don''t know, as it never happens in FF or
Safari.
On 4 Feb, 15:48, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Element#previous could return
> undefined if no previous sibling is found.
>
> Try specifying element tag name:
>
> var caption = link.up().previous(''caption''), image;
> if (caption) {
> ...
>
> }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Well, if "link" is not extended, than calling "up" on it will obviously fail. IE just happens to be "different" from others. See: http://www.prototypejs.org/learn/extensions http://thinkweb2.com/projects/prototype/common-mistakes-and-how-to-avoid-them/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
OK. Now I get it. Not sure why it''s working 80% of the time, but understand now why IE behaves differently to the others. Thanks for the links. Cheers Chris On 4 Feb, 20:44, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Well, if "link" is not extended, than calling "up" on it will > obviously fail. IE just happens to be "different" from others. See: > > http://www.prototypejs.org/learn/extensionshttp://thinkweb2.com/projects/prototype/common-mistakes-and-how-to-av...--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---