I am using the latest 1.5.1.1 stable prototype, and a click observer
added through $$(''a.citation'').invoke to all of the citations
on this
page:
<http://oll.libertyfund.org/index.php?
option=com_staticxt&staticfile=advanced_search.php>
The page works perfectly in Safari 2 and Firefox 2, but stubbornly
navigates to the target of the link when clicked in Safari 1.3.9. I
added a return false to the end of my function just to see if that
might help, even though I know it''s inside an anonymous function.
Does anyone have any bright ideas how I might fix this?
//sample link
<a href="http://oll.libertyfund.org/340/44332/604638"
title="show
citation" class="citation" id="cit_604638"><img
src="static/citation.gif" width="80" height="14"
alt="" /></a>
//script
<script type="text/javascript" charset="utf-8">
$$(''a.citation'').invoke(''observe'',''click'',function(evt){
me = Event.element(evt).parentNode;
uri = me.href.substr(27).split(''/'');
new Ajax.Updater(me.parentNode,
''http://oll.libertyfund.org/ajax_citation.php'',{parameters: {
id:
uri[0], chapter: uri[1], para: uri[2] }, insertion: Insertion.Bottom});
Event.stop(evt);
return false;
});
</script>
Thanks in advance,
Walter
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Forgot to add, you have to actually search for something in order to see them... On Aug 23, 2007, at 7:29 PM, Walter Lee Davis wrote:> > <http://oll.libertyfund.org/index.php? > option=com_staticxt&staticfile=advanced_search.php> >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Martin Bialasinski
2007-Aug-24 00:08 UTC
Re: Event.stop() and Safari 1.3.9 don''t get along
On 8/24/07, Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> The page works perfectly in Safari 2 and Firefox 2, but stubbornly > navigates to the target of the link when clicked in Safari 1.3.9.My Event.stop() function (Prototype 1.4 based): stop: function(event) { if (event.preventDefault) { event.preventDefault(); event.stopPropagation(); if (isKHtml) { var element = Event.element(event); var oldhref = element.href; element.href = ''javascript:void 0''; (function(){ element.href = oldhref; }).delay(1); } } else { event.returnValue = false; event.cancelBubble = true; } }, You will need to adapt it, obviously. .delay() is a setTimeout wrapper and isKHtml is true for Safari. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
In trying to use this, I ended up setting an alert on the result of the
Event.element call:
var el = Event.element(event);
alert (el);
What I get back is object[IMG], when I am expecting an A.
My outer loop is looking for $$(''a.citation''), and feeding the
result
into the anonymous function generator. Why then is the target of the
click event the image rather than the a?
How can I trap this and work around it?
Thanks,
Walter
On Aug 23, 2007, at 8:08 PM, Martin Bialasinski wrote:
>
> On 8/24/07, Walter Lee Davis
<waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:
>> The page works perfectly in Safari 2 and Firefox 2, but stubbornly
>> navigates to the target of the link when clicked in Safari 1.3.9.
>
> My Event.stop() function (Prototype 1.4 based):
>
> stop: function(event) {
> if (event.preventDefault) {
> event.preventDefault();
> event.stopPropagation();
> if (isKHtml) {
> var element = Event.element(event);
> var oldhref = element.href;
> element.href = ''javascript:void 0'';
> (function(){ element.href = oldhref; }).delay(1);
> }
> } else {
> event.returnValue = false;
> event.cancelBubble = true;
> }
> },
>
> You will need to adapt it, obviously. .delay() is a setTimeout wrapper
> and isKHtml is true for Safari.
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
I have this limping along as follows:
var cit_this = function(evt){
Event.stop(evt);
var me = Event.findElement(evt,''a'');
var uri = me.href.substr(27).split(''/'');
if(Prototype.Browser.WebKit == true){ me.href="javascript:;";}
new Ajax.Updater(me.parentNode,
''http://oll.libertyfund.org/ajax_citation.php'',{parameters: {
id:
uri[0], chapter: uri[1], para: uri[2] }, insertion: Insertion.Bottom});
};
$$(''a.citation'').invoke(''observe'',''click'',cit_this);
It seems incredibly hacky, but it works and doesn''t complain in FireBug
or Safari''s JS Console. If anyone has any further illumination they can
shed, I would appreciate it.
Thanks,
Walter
On Aug 23, 2007, at 8:28 PM, Walter Lee Davis wrote:
>
> In trying to use this, I ended up setting an alert on the result of the
> Event.element call:
>
> var el = Event.element(event);
> alert (el);
>
> What I get back is object[IMG], when I am expecting an A.
>
> My outer loop is looking for $$(''a.citation''), and
feeding the result
> into the anonymous function generator. Why then is the target of the
> click event the image rather than the a?
>
> How can I trap this and work around it?
>
> Thanks,
>
> Walter
>
> On Aug 23, 2007, at 8:08 PM, Martin Bialasinski wrote:
>
>>
>> On 8/24/07, Walter Lee Davis
<waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:
>>> The page works perfectly in Safari 2 and Firefox 2, but stubbornly
>>> navigates to the target of the link when clicked in Safari 1.3.9.
>>
>> My Event.stop() function (Prototype 1.4 based):
>>
>> stop: function(event) {
>> if (event.preventDefault) {
>> event.preventDefault();
>> event.stopPropagation();
>> if (isKHtml) {
>> var element = Event.element(event);
>> var oldhref = element.href;
>> element.href = ''javascript:void 0'';
>> (function(){ element.href = oldhref; }).delay(1);
>> }
>> } else {
>> event.returnValue = false;
>> event.cancelBubble = true;
>> }
>> },
>>
>> You will need to adapt it, obviously. .delay() is a setTimeout wrapper
>> and isKHtml is true for Safari.
>>
>>>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---