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 <[EMAIL PROTECTED]> 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to