Hello all, I have been playing with a script that and have it working fine of Firefox. The script performs two functions, initiated by clicking on a link on the page: 1) When clicking on the link it extracts the value of the text within the <a></a> tags and updates a DIV with the contents. 2) It fires of an AJAX request to return some text that is then placed within a different DIV. This is working in Firefox, but in IE does not as I get the following errors. 1) The updated text is always set to be "underfined". 2) The response from the AJAX call seems to have other spurious data after it which is causing problems, the is limited response when the returned data is plain text, though when HTML is returned the updates doe snot happen. Calling link is as below (contained within a DIV with ID=links ): <a href="#" id="Onsite" class="servicelist">On-site Office Support</a> JS is as below <script type="text/javascript"> var test = $(''links''); $(''links'').observe(''click'',function(event) { var element = Event.element(event); if ( element.tagName.toLowerCase() == ''a'' ) { Event.stop(event); $(''servdesc_title'').innerHTML=element.textContent; id = element.getAttribute(''id''); new Ajax.Updater (''servdesc_content'', ''_services.php? servId=''+id, { evalScripts: true , onComplete: function () { aa=true; } } ); } }.bindAsEventListener()); </script> any help appreciqted. BBBS --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
bbbs wrote:> $(''links'').observe(''click'',function(event)The A tag might not have a click event to observe. Stupid but it''s true. This steaming pile of code might add one: try { HTMLElement.prototype.click = function() { var evt = this.ownerDocument.createEvent(''MouseEvents''); evt.initMouseEvent( ''click'', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null ); this.dispatchEvent(evt); } } catch(e) {} If not, someone with more prototype experience will rescue you from me. Either way, report back here what worked! -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hmm, not sure if this is the problem in my case. I know the AJAX request and response are being triggered as I am running a HTTP listener and can see the request and responses. I''ll certainly take a look at your code more closely though, Many thanks, On 18/02/07, Phlip <phlip2005-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > bbbs wrote: > > > $(''links'').observe(''click'',function(event) > > The A tag might not have a click event to observe. Stupid but it''s true. > > This steaming pile of code might add one: > > try { > HTMLElement.prototype.click = function() > { > var evt = this.ownerDocument.createEvent(''MouseEvents''); > evt.initMouseEvent( ''click'', true, true, > this.ownerDocument.defaultView, > 1, 0, 0, 0, 0, false, false, > false, false, 0, null ); > this.dispatchEvent(evt); > } > } catch(e) {} > > If not, someone with more prototype experience will rescue you from me. > Either way, report back here what worked! > > -- > Phlip > http://www.greencheese.us/ZeekLand <-- NOT a blog!!! > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> I''ve never had problems with links firing click events...<br> IE doesn''t support textContent, maybe other browsers too.. See <a class="moz-txt-link-freetext" href="http://www.quirksmode.org/dom/w3c_html.html">http://www.quirksmode.org/dom/w3c_html.html</a><br> <br> Change the one line to this:<br> $(''servdesc_title'').innerHTML= element.textContent || element.innerText;<br> <br> As for 2), I don''t know what''s going on, we''ll need more details, preferably a live demo.<br> <br> Colin<br> <br> Phlip wrote: <blockquote cite="mid:04eb01c753a7$fa056590$6601a8c0@Marley" type="cite"> <pre wrap="">bbbs wrote: </pre> <blockquote type="cite"> <pre wrap=""> $(''links'').observe(''click'',function(event) </pre> </blockquote> <pre wrap=""><!----> The A tag might not have a click event to observe. Stupid but it''s true. This steaming pile of code might add one: try { HTMLElement.prototype.click = function() { var evt = this.ownerDocument.createEvent(''MouseEvents''); evt.initMouseEvent( ''click'', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null ); this.dispatchEvent(evt); } } catch(e) {} If not, someone with more prototype experience will rescue you from me. Either way, report back here what worked! </pre> </blockquote> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. <br> To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en <br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>
Grate the issue (1) is fixed, still struggling with (2) though demo can be seen at http://executarial.co.uk/test/services.php appreciate the help, BBBS On 18/02/07, Colin Mollenhour <eliteii92g-NPSFNn/7+NYVo650/ln6uw@public.gmane.org> wrote:> > I''ve never had problems with links firing click events... > IE doesn''t support textContent, maybe other browsers too.. See > http://www.quirksmode.org/dom/w3c_html.html > > Change the one line to this: > $(''servdesc_title'').innerHTML= element.textContent || element.innerText; > > As for 2), I don''t know what''s going on, we''ll need more details, > preferably a live demo. > > Colin > > Phlip wrote: > > bbbs wrote: > > $(''links'').observe(''click'',function(event) > > The A tag might not have a click event to observe. Stupid but it''s true. > > This steaming pile of code might add one: > > try { > HTMLElement.prototype.click = function() > { > var evt = this.ownerDocument.createEvent(''MouseEvents''); > evt.initMouseEvent( ''click'', true, true, > this.ownerDocument.defaultView, > 1, 0, 0, 0, 0, false, false, > false, false, 0, null ); > this.dispatchEvent(evt); > } > } catch(e) {} > > If not, someone with more prototype experience will rescue you from me. > Either way, report back here what worked! > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ahh! solved it, the target for the AJAX update was mistakenly a <P> tag, changed it to a <DIV> and all works fine now. On 18/02/07, Richard Kavanagh <bbbs.bbbs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Grate the issue (1) is fixed, still struggling with (2) though > > demo can be seen at http://executarial.co.uk/test/services.php > > appreciate the help, > BBBS > > On 18/02/07, Colin Mollenhour <eliteii92g-NPSFNn/7+NYVo650/ln6uw@public.gmane.org> wrote: > > > > I''ve never had problems with links firing click events... > > IE doesn''t support textContent, maybe other browsers too.. See > > http://www.quirksmode.org/dom/w3c_html.html > > > > Change the one line to this: > > $(''servdesc_title'').innerHTML= element.textContent || element.innerText; > > > > As for 2), I don''t know what''s going on, we''ll need more details, > > preferably a live demo. > > > > Colin > > > > Phlip wrote: > > > > bbbs wrote: > > > > $(''links'').observe(''click'',function(event) > > > > The A tag might not have a click event to observe. Stupid but it''s true. > > > > This steaming pile of code might add one: > > > > try { > > HTMLElement.prototype.click = function() > > { > > var evt > > this.ownerDocument.createEvent(''MouseEvents''); > > evt.initMouseEvent( ''click'', true, true, > > this.ownerDocument.defaultView, > > 1, 0, 0, 0, 0, false, false, > > > > false, false, 0, null ); > > this.dispatchEvent(evt); > > } > > } catch(e) {} > > > > If not, someone with more prototype experience will rescue you from me. > > Either way, report back here what worked! > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---