First of all I''d like to say thanks for all the great work everyone has
put
into scriptaculous,
I''m having a lot of fun playing with the framework, and easily moving
into
Web 2.0 territory.
I''ve just hit a snag on my project though.
So here''s my code:
...
var newEvent "<div
id=''item_"+theDate+"''
style=''display:none''>"+
" <div class=''msghead''><img
src=''images/trash.gif''
class=''trash'' onclick=''new
Effect.Fade(\''item_"+theDate+"\'',{duration:0.3
});''>"+theLongDate+"</div>"+
" <div class=''msg''>Something happens
today</div>"+
"</div>";
...
new Insertion.Before(theID,newSched);
I keep getting syntax errors right after "Fade(" no matter how I try
to
escape the quote characters!
Am I doing this the wrong way, because it seems all these quotes could get
out of hand really fast.
Also, I would like to suggest, if feasible, that you make the wiki
downloadable for offline viewing,
especially since it seems to disappear or slow to a halt every now and then.
Thanks
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
===========================
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
In your code, the img tag is left open. Is that the problem?
I would anyways keep a skeleton div in the original <body>, then copy it
whenever necessary and change the required attributes before doing
insertion.before()
Something like...
<body>
....
<div id="placeholder_event_div"
style="display:none">
<div class="msghead"><img
src="images/trash.gif" class="trash" /><span
class="eventText"></span></div>
<div class=''msg''></div>
</div>
....
</body>
in the script...
...
var newEvent = $("placeholder_event_div").cloneNode(true);
var msgHeadEl = document.getElementsByClassName("trash", newEvent);
msgHeadEl.onclick = new Effect.Fade(...);
document.getElementsByClassName("eventText", newEvent)[0].innerHTML
theLongDate;
document.getElementsByClassName("msg", newEvent)[0].innerHTML =
whatever;
...
new Insertion.Before(....);
Cheers,
Amol Katdare
On 12/17/05, Brian Peiris
<brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> First of all I''d like to say thanks for all the great work
everyone has
> put into scriptaculous,
> I''m having a lot of fun playing with the framework, and easily
moving into
> Web 2.0 territory.
> I''ve just hit a snag on my project though.
> So here''s my code:
> ...
> var newEvent> "<div
id=''item_"+theDate+"''
style=''display:none''>"+
> " <div class=''msghead''><img
src=''images/trash.gif''
> class=''trash'' onclick=''new
Effect.Fade(\''item_"+theDate+"\'',{duration:0.3
> });''>"+theLongDate+"</div>"+
> " <div class=''msg''>Something
happens today</div>"+
> "</div>";
> ...
> new Insertion.Before(theID,newSched);
>
> I keep getting syntax errors right after "Fade(" no matter how I
try to
> escape the quote characters!
> Am I doing this the wrong way, because it seems all these quotes could get
> out of hand really fast.
>
> Also, I would like to suggest, if feasible, that you make the wiki
> downloadable for offline viewing,
> especially since it seems to disappear or slow to a halt every now and
> then.
>
> Thanks
> --
> ===========================> Brian Peiris
> Brampton, Ontario, Canada
> brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> ===========================>
_______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
>
>
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Great, that''s a whole lot better. but what do I insert now, I need a content string don''t I. I can''t just insert the newEvent object, right? Thanks, Brian Peiris On 12/18/05, Amol Katdare <amol.forums-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > In your code, the img tag is left open. Is that the problem? > > I would anyways keep a skeleton div in the original <body>, then copy it > whenever necessary and change the required attributes before doing > insertion.before() > > Something like... > > <body> > .... > <div id="placeholder_event_div" style="display:none"> > <div class="msghead"><img src="images/trash.gif" class="trash" /><span > class="eventText"></span></div> > <div class=''msg''></div> > </div> > .... > </body> > > in the script... > ... > var newEvent = $("placeholder_event_div").cloneNode(true); > var msgHeadEl = document.getElementsByClassName("trash", newEvent); > msgHeadEl.onclick = new Effect.Fade(...); > document.getElementsByClassName("eventText", newEvent)[0].innerHTML > theLongDate; > document.getElementsByClassName("msg", newEvent)[0].innerHTML = whatever; > ... > new Insertion.Before(....); > > > Cheers, > Amol Katdare > > > On 12/17/05, Brian Peiris <brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > First of all I''d like to say thanks for all the great work everyone has > > put into scriptaculous, > > I''m having a lot of fun playing with the framework, and easily moving > > into Web 2.0 territory. > > I''ve just hit a snag on my project though. > > So here''s my code: > > ... > > var newEvent> > "<div id=''item_"+theDate+"'' style=''display:none''>"+ > > " <div class=''msghead''><img src=''images/trash.gif'' > > class=''trash'' onclick=''new Effect.Fade(\''item_"+theDate+"\'',{duration: > > 0.3});''>"+theLongDate+"</div>"+ > > " <div class=''msg''>Something happens today</div>"+ > > "</div>"; > > ... > > new Insertion.Before(theID,newSched); > > > > I keep getting syntax errors right after "Fade(" no matter how I try to > > escape the quote characters! > > Am I doing this the wrong way, because it seems all these quotes could > > get out of hand really fast. > > > > Also, I would like to suggest, if feasible, that you make the wiki > > downloadable for offline viewing, > > especially since it seems to disappear or slow to a halt every now and > > then. > > > > Thanks > > -- > > ===========================> > Brian Peiris > > Brampton, Ontario, Canada > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > > ===========================> > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- ===========================Brian Peiris Brampton, Ontario, Canada brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org =========================== _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
hmm... I have never used prototype''s Insertion functionality. But new Insertion.Before(theID, newEvent.outerHTML) should work. Alternatively, take a look at appendChild [ http://www.mozilla.org/docs/dom/domref/dom_el_ref32.html#1028327 ] or insertBefore [ http://www.mozilla.org/docs/dom/domref/dom_el_ref47.html#1028897 ] Amol Katdare On 12/18/05, Brian Peiris <brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Great, that''s a whole lot better. > but what do I insert now, I need a content string don''t I. > I can''t just insert the newEvent object, right? > > Thanks, > Brian Peiris > > On 12/18/05, Amol Katdare <amol.forums-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > In your code, the img tag is left open. Is that the problem? > > > > I would anyways keep a skeleton div in the original <body>, then copy it > > whenever necessary and change the required attributes before doing > > insertion.before() > > > > Something like... > > > > <body> > > .... > > <div id="placeholder_event_div" style="display:none"> > > <div class="msghead"><img src="images/trash.gif" class="trash" > > /><span class="eventText"></span></div> > > <div class=''msg''></div> > > </div> > > .... > > </body> > > > > in the script... > > ... > > var newEvent = $("placeholder_event_div").cloneNode(true); > > var msgHeadEl = document.getElementsByClassName("trash", newEvent); > > msgHeadEl.onclick = new Effect.Fade(...); > > document.getElementsByClassName("eventText", newEvent)[0].innerHTML > > theLongDate; > > document.getElementsByClassName("msg", newEvent)[0].innerHTML > > whatever; > > ... > > new Insertion.Before(....); > > > > > > Cheers, > > Amol Katdare > > > > > > On 12/17/05, Brian Peiris < brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > First of all I''d like to say thanks for all the great work everyone > > > has put into scriptaculous, > > > I''m having a lot of fun playing with the framework, and easily moving > > > into Web 2.0 territory. > > > I''ve just hit a snag on my project though. > > > So here''s my code: > > > ... > > > var newEvent> > > "<div id=''item_"+theDate+"'' style=''display:none''>"+ > > > " <div class=''msghead''><img src=''images/trash.gif'' > > > class=''trash'' onclick=''new Effect.Fade(\''item_"+theDate+"\'',{duration: > > > 0.3});''>"+theLongDate+"</div>"+ > > > " <div class=''msg''>Something happens today</div>"+ > > > "</div>"; > > > ... > > > new Insertion.Before(theID,newSched); > > > > > > I keep getting syntax errors right after "Fade(" no matter how I try > > > to escape the quote characters! > > > Am I doing this the wrong way, because it seems all these quotes could > > > get out of hand really fast. > > > > > > Also, I would like to suggest, if feasible, that you make the wiki > > > downloadable for offline viewing, > > > especially since it seems to disappear or slow to a halt every now and > > > then. > > > > > > Thanks > > > -- > > > ===========================> > > Brian Peiris > > > Brampton, Ontario, Canada > > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > > > ===========================> > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > -- > ===========================> Brian Peiris > Brampton, Ontario, Canada > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > ===========================> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
The outerHTML property is not available on all browsers (namely not on Firefox). Stumbled upon this just today. -Thomas Am 18.12.2005 um 21:08 schrieb Amol Katdare:> hmm... > I have never used prototype''s Insertion functionality. > But new Insertion.Before(theID, newEvent.outerHTML) should work. >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I have some code that that adds an Element.replace() method to Prototype. This uses outerHTML if it''s available and other DOM magic on Firefox. I''ve sent this to Sam for possible inclusion in future versions of Prototype. http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-bette r-replace-semantics ________________________________ From: Thomas Fuchs [mailto:t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org] Sent: Sunday, December 18, 2005 12:48 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] problems with quotes and escaping The outerHTML property is not available on all browsers (namely not on Firefox). Stumbled upon this just today. -Thomas Am 18.12.2005 um 21:08 schrieb Amol Katdare: hmm... I have never used prototype''s Insertion functionality. But new Insertion.Before(theID, newEvent.outerHTML) should work. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
OK, I''ll try it out when I get a chance, One more thing, it seems msgHeadEl.onclick = "new Effect.Fade(...);"; doesn''t work in firefox, only IE as far as I''ve tested. can anyone suggest a solution? Thanks, Brian Peiris On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:> > I have some code that that adds an Element.replace() method to > Prototype. This uses outerHTML if it''s available and other DOM magic on > Firefox. > > > > I''ve sent this to Sam for possible inclusion in future versions of > Prototype. > > > > > http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-better-replace-semantics > > > ------------------------------ > > *From:* Thomas Fuchs [mailto:t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org] > *Sent:* Sunday, December 18, 2005 12:48 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] problems with quotes and escaping > > > > The outerHTML property is not available on all browsers (namely not on > Firefox). > > Stumbled upon this just today. > > > > -Thomas > > > > Am 18.12.2005 um 21:08 schrieb Amol Katdare: > > > > hmm... > I have never used prototype''s Insertion functionality. > But *new Insertion.Before(theID, newEvent.outerHTML)* should work. > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- ===========================Brian Peiris Brampton, Ontario, Canada brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org =========================== _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
This should work:
msgHeadEl.onclick = function() {new Effect.Fade(...);};
________________________________
From: Brian Peiris [mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Sunday, December 18, 2005 1:56 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
OK, I''ll try it out when I get a chance,
One more thing, it seems
msgHeadEl.onclick = "new Effect.Fade(...);";
doesn''t work in firefox, only IE as far as I''ve tested.
can anyone suggest a solution?
Thanks,
Brian Peiris
On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org>
wrote:
I have some code that that adds an Element.replace() method to
Prototype. This uses outerHTML if it''s available and other DOM magic
on
Firefox.
I''ve sent this to Sam for possible inclusion in future versions of
Prototype.
http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-bette
r-replace-semantics
________________________________
From: Thomas Fuchs [mailto:t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org]
Sent: Sunday, December 18, 2005 12:48 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
The outerHTML property is not available on all browsers (namely not on
Firefox).
Stumbled upon this just today.
-Thomas
Am 18.12.2005 um 21:08 schrieb Amol Katdare:
hmm...
I have never used prototype''s Insertion functionality.
But new Insertion.Before(theID, newEvent.outerHTML) should work.
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
============================
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Nope, still doesn''t work. On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:> > This should work: > > > > msgHeadEl.onclick = function() {new Effect.Fade(...);}; > > > ------------------------------ > > *From:* Brian Peiris [mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > *Sent:* Sunday, December 18, 2005 1:56 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] problems with quotes and escaping > > > > OK, I''ll try it out when I get a chance, > One more thing, it seems > msgHeadEl.onclick = "new Effect.Fade(...);"; > doesn''t work in firefox, only IE as far as I''ve tested. > can anyone suggest a solution? > Thanks, > Brian Peiris > > On 12/18/05, *Tom Fakes* <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > I have some code that that adds an Element.replace() method to Prototype. > This uses outerHTML if it''s available and other DOM magic on Firefox. > > > > I''ve sent this to Sam for possible inclusion in future versions of > Prototype. > > > > > http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-better-replace-semantics > > > ------------------------------ > > *From:* Thomas Fuchs [mailto:t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org] > *Sent:* Sunday, December 18, 2005 12:48 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] problems with quotes and escaping > > > > The outerHTML property is not available on all browsers (namely not on > Firefox). > > Stumbled upon this just today. > > > > -Thomas > > > > Am 18.12.2005 um 21:08 schrieb Amol Katdare: > > > > hmm... > I have never used prototype''s Insertion functionality. > But *new Insertion.Before(theID, newEvent.outerHTML)* should work. > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > -- > ===========================> Brian Peiris > Brampton, Ontario, Canada > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > ===========================> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- ===========================Brian Peiris Brampton, Ontario, Canada brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org =========================== _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I''m assuming here that msgHeadEl isn''t just the ID of the
element. If
it is, then you need to do this:
$(''msgHeadEl'').onclick = function() {new Effect.Fade(...);};
The $() function in Prototype will look up the ID in the DOM in a way
that is compatible across browsers and return the element object you can
then manipulate.
________________________________
From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]
On Behalf Of Brian
Peiris
Sent: Sunday, December 18, 2005 7:08 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
Nope, still doesn''t work.
On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org>
wrote:
This should work:
msgHeadEl.onclick = function() {new Effect.Fade(...);};
________________________________
From: Brian Peiris [mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Sunday, December 18, 2005 1:56 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
OK, I''ll try it out when I get a chance,
One more thing, it seems
msgHeadEl.onclick = "new Effect.Fade(...);";
doesn''t work in firefox, only IE as far as I''ve tested.
can anyone suggest a solution?
Thanks,
Brian Peiris
On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org>
wrote:
I have some code that that adds an Element.replace() method to
Prototype. This uses outerHTML if it''s available and other DOM magic
on
Firefox.
I''ve sent this to Sam for possible inclusion in future versions of
Prototype.
http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-bette
r-replace-semantics
________________________________
From: Thomas Fuchs [mailto: t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org]
Sent: Sunday, December 18, 2005 12:48 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
The outerHTML property is not available on all browsers (namely not on
Firefox).
Stumbled upon this just today.
-Thomas
Am 18.12.2005 um 21:08 schrieb Amol Katdare:
hmm...
I have never used prototype''s Insertion functionality.
But new Insertion.Before(theID, newEvent.outerHTML) should work.
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
============================
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
============================
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Yes msgHeadEl is an img element, not a string, see Amol Katdare''s first reply in this thread for more detailed code. Thanks, Brian Peiris On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:> > I''m assuming here that msgHeadEl isn''t just the ID of the element. If it > is, then you need to do this: > > $(''msgHeadEl'').onclick = function() {new Effect.Fade(...);}; > > The $() function in Prototype will look up the ID in the DOM in a way that > is compatible across browsers and return the element object you can then > manipulate. > > > > > ------------------------------ > > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] *On Behalf Of *Brian Peiris > *Sent:* Sunday, December 18, 2005 7:08 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] problems with quotes and escaping > > > > Nope, still doesn''t work. > > On 12/18/05, *Tom Fakes* <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > This should work: > > > > msgHeadEl.onclick = function() {new Effect.Fade(...);}; > > > ------------------------------ > > *From:* Brian Peiris [mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > *Sent:* Sunday, December 18, 2005 1:56 PM > > > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] problems with quotes and escaping > > > > OK, I''ll try it out when I get a chance, > One more thing, it seems > msgHeadEl.onclick = "new Effect.Fade(...);"; > doesn''t work in firefox, only IE as far as I''ve tested. > can anyone suggest a solution? > Thanks, > Brian Peiris > > On 12/18/05, *Tom Fakes* <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > I have some code that that adds an Element.replace() method to Prototype. > This uses outerHTML if it''s available and other DOM magic on Firefox. > > > > I''ve sent this to Sam for possible inclusion in future versions of > Prototype. > > > > > http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-better-replace-semantics > > > ------------------------------ > > *From:* Thomas Fuchs [mailto: t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org] > *Sent:* Sunday, December 18, 2005 12:48 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] problems with quotes and escaping > > > > The outerHTML property is not available on all browsers (namely not on > Firefox). > > Stumbled upon this just today. > > > > -Thomas > > > > Am 18.12.2005 um 21:08 schrieb Amol Katdare: > > > > hmm... > I have never used prototype''s Insertion functionality. > But *new Insertion.Before(theID, newEvent.outerHTML)* should work. > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > -- > ===========================> Brian Peiris > Brampton, Ontario, Canada > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > ===========================> > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > -- > ===========================> Brian Peiris > Brampton, Ontario, Canada > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > ===========================> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- ===========================Brian Peiris Brampton, Ontario, Canada brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org =========================== _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Oh yeh, I see it:
var msgHeadEl = document.getElementsByClassName("trash", newEvent);
getElementsByClassName returns a collection, not a single element. You
need to set the onclick handler for each element in the collection.
________________________________
From: Brian Peiris [mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Sunday, December 18, 2005 8:00 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
Yes msgHeadEl is an img element, not a string, see Amol Katdare''s first
reply in this thread for more detailed code.
Thanks,
Brian Peiris
On 12/18/05, Tom Fakes < Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org
<mailto:Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> >
wrote:
I''m assuming here that msgHeadEl isn''t just the ID of the
element. If
it is, then you need to do this:
$(''msgHeadEl'').onclick = function() {new Effect.Fade(...);};
The $() function in Prototype will look up the ID in the DOM in a way
that is compatible across browsers and return the element object you can
then manipulate.
________________________________
From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]
On Behalf Of Brian
Peiris
Sent: Sunday, December 18, 2005 7:08 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
Nope, still doesn''t work.
On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org>
wrote:
This should work:
msgHeadEl.onclick = function() {new Effect.Fade(...);};
________________________________
From: Brian Peiris [mailto: brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Sunday, December 18, 2005 1:56 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
OK, I''ll try it out when I get a chance,
One more thing, it seems
msgHeadEl.onclick = "new Effect.Fade(...);";
doesn''t work in firefox, only IE as far as I''ve tested.
can anyone suggest a solution?
Thanks,
Brian Peiris
On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org>
wrote:
I have some code that that adds an Element.replace() method to
Prototype. This uses outerHTML if it''s available and other DOM magic
on
Firefox.
I''ve sent this to Sam for possible inclusion in future versions of
Prototype.
http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-bette
r-replace-semantics
________________________________
From: Thomas Fuchs [mailto: t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org]
Sent: Sunday, December 18, 2005 12:48 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
The outerHTML property is not available on all browsers (namely not on
Firefox).
Stumbled upon this just today.
-Thomas
Am 18.12.2005 um 21:08 schrieb Amol Katdare:
hmm...
I have never used prototype''s Insertion functionality.
But new Insertion.Before(theID, newEvent.outerHTML) should work.
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
============================
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
============================
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
============================
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
sorry, I''ve fixed that already, still doesn''t work On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:> > Oh yeh, I see it: > > > > var msgHeadEl = document.getElementsByClassName("trash", newEvent); > > > > getElementsByClassName returns a collection, not a single element. You > need to set the onclick handler for each element in the collection. > > > ------------------------------ > > *From:* Brian Peiris [mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > *Sent:* Sunday, December 18, 2005 8:00 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] problems with quotes and escaping > > > > Yes msgHeadEl is an img element, not a string, see Amol Katdare''s first > reply in this thread for more detailed code. > Thanks, > Brian Peiris > > On 12/18/05, *Tom Fakes* < Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > I''m assuming here that msgHeadEl isn''t just the ID of the element. If it > is, then you need to do this: > > $(''msgHeadEl'').onclick = function() {new Effect.Fade(...);}; > > The $() function in Prototype will look up the ID in the DOM in a way that > is compatible across browsers and return the element object you can then > manipulate. > > > > > ------------------------------ > > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] *On Behalf Of *Brian Peiris > *Sent:* Sunday, December 18, 2005 7:08 PM > > > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] problems with quotes and escaping > > > > Nope, still doesn''t work. > > On 12/18/05, *Tom Fakes* <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > This should work: > > > > msgHeadEl.onclick = function() {new Effect.Fade(...);}; > > > ------------------------------ > > *From:* Brian Peiris [mailto: brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > *Sent:* Sunday, December 18, 2005 1:56 PM > > > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] problems with quotes and escaping > > > > OK, I''ll try it out when I get a chance, > One more thing, it seems > msgHeadEl.onclick = "new Effect.Fade(...);"; > doesn''t work in firefox, only IE as far as I''ve tested. > can anyone suggest a solution? > Thanks, > Brian Peiris > > On 12/18/05, *Tom Fakes* <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > I have some code that that adds an Element.replace() method to Prototype. > This uses outerHTML if it''s available and other DOM magic on Firefox. > > > > I''ve sent this to Sam for possible inclusion in future versions of > Prototype. > > > > > http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-better-replace-semantics > > > ------------------------------ > > *From:* Thomas Fuchs [mailto: t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org] > *Sent:* Sunday, December 18, 2005 12:48 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] problems with quotes and escaping > > > > The outerHTML property is not available on all browsers (namely not on > Firefox). > > Stumbled upon this just today. > > > > -Thomas > > > > Am 18.12.2005 um 21:08 schrieb Amol Katdare: > > > > hmm... > I have never used prototype''s Insertion functionality. > But *new Insertion.Before(theID, newEvent.outerHTML)* should work. > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > -- > ===========================> Brian Peiris > Brampton, Ontario, Canada > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > ===========================> > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > -- > ===========================> Brian Peiris > Brampton, Ontario, Canada > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > ===========================> > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > -- > ===========================> Brian Peiris > Brampton, Ontario, Canada > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > ===========================> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- ===========================Brian Peiris Brampton, Ontario, Canada brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org =========================== _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Here''s my code:
var msgHeadEl = document.getElementsByClassName("trash", newEvent)[0];
msgHeadEl.onclick = "alert(''hello'')"; //This works
in IE but not in firefox
// msgHeadEl.onclick = function() {alert(''hello'');}; //This
doesn''t work at all
//msgHeadEl.onclick = "function()
{alert(''hello'');};" //neither does this
On 12/18/05, Brian Peiris
<brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> sorry, I''ve fixed that already, still doesn''t work
>
>
>
> On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org>
wrote:
> >
> >
> >
> > Oh yeh, I see it:
> >
> >
> >
> > var msgHeadEl = document.getElementsByClassName("trash",
newEvent);
> >
> >
> >
> > getElementsByClassName returns a collection, not a single element.
You need to set the onclick handler for each element in the collection.
> >
> >
> >
> > ________________________________
> >
> > From: Brian Peiris
[mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
> > Sent: Sunday, December 18, 2005 8:00 PM
> >
> > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> >
> >
> >
> >
> > Yes msgHeadEl is an img element, not a string, see Amol
Katdare''s first reply in this thread for more detailed code.
> > Thanks,
> > Brian Peiris
> >
> >
> > On 12/18/05, Tom Fakes <
Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> >
> >
> > I''m assuming here that msgHeadEl isn''t just the ID
of the element. If it is, then you need to do this:
> >
> > $(''msgHeadEl'').onclick = function() {new
Effect.Fade(...);};
> >
> > The $() function in Prototype will look up the ID in the DOM in a way
that is compatible across browsers and return the element object you can then
manipulate.
> >
> >
> >
> >
> >
> > ________________________________
> >
> > From:
rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]
On Behalf Of Brian Peiris
> > Sent: Sunday, December 18, 2005 7:08 PM
> >
> >
> >
> > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> >
> >
> >
> >
> > Nope, still doesn''t work.
> >
> >
> > On 12/18/05, Tom Fakes
<Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> >
> >
> > This should work:
> >
> >
> >
> > msgHeadEl.onclick = function() {new Effect.Fade(...);};
> >
> >
> >
> > ________________________________
> >
> > From: Brian Peiris [mailto:
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
> > Sent: Sunday, December 18, 2005 1:56 PM
> >
> >
> >
> > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> >
> >
> >
> >
> > OK, I''ll try it out when I get a chance,
> > One more thing, it seems
> > msgHeadEl.onclick = "new Effect.Fade(...);";
> > doesn''t work in firefox, only IE as far as I''ve
tested.
> > can anyone suggest a solution?
> > Thanks,
> > Brian Peiris
> >
> >
> > On 12/18/05, Tom Fakes
<Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> >
> >
> > I have some code that that adds an Element.replace() method to
Prototype. This uses outerHTML if it''s available and other DOM magic
on Firefox.
> >
> >
> >
> > I''ve sent this to Sam for possible inclusion in future
versions of Prototype.
> >
> >
> >
> >
http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-better-replace-semantics
> >
> >
> >
> > ________________________________
> >
> > From: Thomas Fuchs [mailto:
t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org]
> > Sent: Sunday, December 18, 2005 12:48 PM
> > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> >
> >
> >
> >
> >
> > The outerHTML property is not available on all browsers (namely not on
Firefox).
> >
> >
> > Stumbled upon this just today.
> >
> >
> >
> >
> >
> > -Thomas
> >
> >
> >
> >
> >
> > Am 18.12.2005 um 21:08 schrieb Amol Katdare:
> >
> >
> >
> > hmm...
> > I have never used prototype''s Insertion functionality.
> > But new Insertion.Before(theID, newEvent.outerHTML) should work.
> >
> >
> > _______________________________________________
> > Rails-spinoffs mailing list
> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> >
> >
> >
> >
> > --
> > ===========================> > Brian Peiris
> > Brampton, Ontario, Canada
> > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > ===========================> >
> >
> > _______________________________________________
> > Rails-spinoffs mailing list
> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> >
> >
> >
> >
> > --
> > ===========================> > Brian Peiris
> > Brampton, Ontario, Canada
> > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > ===========================> >
> >
> > _______________________________________________
> > Rails-spinoffs mailing list
> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> >
> >
> >
> >
> >
> >
> > --
> > ===========================> > Brian Peiris
> > Brampton, Ontario, Canada
> > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > ===========================> >
_______________________________________________
> > Rails-spinoffs mailing list
> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> >
> >
> >
>
>
>
> --
> ===========================> Brian Peiris
> Brampton, Ontario, Canada
> brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> ===========================
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
============================
I have almost the same code (simplified here) and it works for me:
<div class="container" id="bar">
<div class="data">
<img border="0" class="foo" ... />
</div>
</div>
<script>
var el = document.getElementsByClassName("foo",
$(''bar''))[0];
el.onclick = function() { alert(''Hi''); };
</script>
Check the Firefox Javascript console to see if there are any errors from
somewhere else in the code.
-----Original Message-----
From: Brian Peiris [mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Sunday, December 18, 2005 8:17 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
Here''s my code:
var msgHeadEl = document.getElementsByClassName("trash", newEvent)[0];
msgHeadEl.onclick = "alert(''hello'')"; //This works
in IE but not in
firefox
// msgHeadEl.onclick = function() {alert(''hello'');}; //This
doesn''t work
at all
//msgHeadEl.onclick = "function()
{alert(''hello'');};" //neither does
this
On 12/18/05, Brian Peiris
<brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> sorry, I''ve fixed that already, still doesn''t work
>
>
>
> On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org>
wrote:
> >
> >
> >
> > Oh yeh, I see it:
> >
> >
> >
> > var msgHeadEl = document.getElementsByClassName("trash",
newEvent);> >
> >
> >
> > getElementsByClassName returns a collection, not a single element.
You need to set the onclick handler for each element in the
collection.> >
> >
> >
> > ________________________________
> >
> > From: Brian Peiris
[mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
> > Sent: Sunday, December 18, 2005 8:00 PM
> >
> > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> >
> >
> >
> >
> > Yes msgHeadEl is an img element, not a string, see Amol
Katdare''s
first reply in this thread for more detailed code.> > Thanks,
> > Brian Peiris
> >
> >
> > On 12/18/05, Tom Fakes <
Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> >
> >
> > I''m assuming here that msgHeadEl isn''t just the ID
of the element.
If it is, then you need to do this:> >
> > $(''msgHeadEl'').onclick = function() {new
Effect.Fade(...);};
> >
> > The $() function in Prototype will look up the ID in the DOM in a
way that is compatible across browsers and return the element object you
can then manipulate.> >
> >
> >
> >
> >
> > ________________________________
> >
> > From:
rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]
On Behalf Of
Brian Peiris> > Sent: Sunday, December 18, 2005 7:08 PM
> >
> >
> >
> > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> >
> >
> >
> >
> > Nope, still doesn''t work.
> >
> >
> > On 12/18/05, Tom Fakes
<Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> >
> >
> > This should work:
> >
> >
> >
> > msgHeadEl.onclick = function() {new Effect.Fade(...);};
> >
> >
> >
> > ________________________________
> >
> > From: Brian Peiris [mailto:
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
> > Sent: Sunday, December 18, 2005 1:56 PM
> >
> >
> >
> > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> >
> >
> >
> >
> > OK, I''ll try it out when I get a chance,
> > One more thing, it seems
> > msgHeadEl.onclick = "new Effect.Fade(...);";
> > doesn''t work in firefox, only IE as far as I''ve
tested.
> > can anyone suggest a solution?
> > Thanks,
> > Brian Peiris
> >
> >
> > On 12/18/05, Tom Fakes
<Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> >
> >
> > I have some code that that adds an Element.replace() method to
Prototype. This uses outerHTML if it''s available and other DOM magic
on
Firefox.> >
> >
> >
> > I''ve sent this to Sam for possible inclusion in future
versions of
Prototype.> >
> >
> >
> >
http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-bette
r-replace-semantics> >
> >
> >
> > ________________________________
> >
> > From: Thomas Fuchs [mailto:
t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org]
> > Sent: Sunday, December 18, 2005 12:48 PM
> > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> >
> >
> >
> >
> >
> > The outerHTML property is not available on all browsers (namely not
on Firefox).> >
> >
> > Stumbled upon this just today.
> >
> >
> >
> >
> >
> > -Thomas
> >
> >
> >
> >
> >
> > Am 18.12.2005 um 21:08 schrieb Amol Katdare:
> >
> >
> >
> > hmm...
> > I have never used prototype''s Insertion functionality.
> > But new Insertion.Before(theID, newEvent.outerHTML) should work.
> >
> >
> > _______________________________________________
> > Rails-spinoffs mailing list
> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> >
> >
> >
> >
> > --
> > ===========================> > Brian Peiris
> > Brampton, Ontario, Canada
> > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > ===========================> >
> >
> > _______________________________________________
> > Rails-spinoffs mailing list
> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> >
> >
> >
> >
> > --
> > ===========================> > Brian Peiris
> > Brampton, Ontario, Canada
> > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > ===========================> >
> >
> > _______________________________________________
> > Rails-spinoffs mailing list
> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> >
> >
> >
> >
> >
> >
> > --
> > ===========================> > Brian Peiris
> > Brampton, Ontario, Canada
> > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > ===========================> >
_______________________________________________
> > Rails-spinoffs mailing list
> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> >
> >
> >
>
>
>
> --
> ===========================> Brian Peiris
> Brampton, Ontario, Canada
> brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> ===========================
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
===========================_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Full test code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script src="js/prototype.js" type="text/javascript">
</script>
<script src="js/scriptaculous.js"
type="text/javascript">
</script>
<title></title>
</head>
<body>
<div style="background-color:lightblue;" id="bar">
1
<div class="data">
<img border="0" class="foo">
</div>
</div>
<div id="placeholder_event_div"
style="display:none;">
<div class="data">
<img border="0" class="foo">
</div>
</div>
<script type="text/javascript">
var newEvent = $("placeholder_event_div").cloneNode(true);
var el = document.getElementsByClassName("foo", newEvent)[0];
//el.onclick = "alert(''hello'')"; //This works in
IE but not in firefox
el.onclick = function() {alert(''hello'');}; //This
doesn''t work at all
new Insertion.Before("placeholder_event_div","<div
style=''background-color:lightblue;''>2"+newEvent.innerHTML+"<\/div>");
</script>
</body>
</html>
On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org>
wrote:> I have almost the same code (simplified here) and it works for me:
>
> <div class="container" id="bar">
> <div class="data">
> <img border="0" class="foo"
... />
> </div>
> </div>
> <script>
> var el = document.getElementsByClassName("foo",
> $(''bar''))[0];
> el.onclick = function() { alert(''Hi''); };
> </script>
>
> Check the Firefox Javascript console to see if there are any errors from
> somewhere else in the code.
>
> -----Original Message-----
> From: Brian Peiris
[mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
> Sent: Sunday, December 18, 2005 8:17 PM
> To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Subject: Re: [Rails-spinoffs] problems with quotes and escaping
>
> Here''s my code:
> var msgHeadEl = document.getElementsByClassName("trash",
newEvent)[0];
> msgHeadEl.onclick = "alert(''hello'')"; //This
works in IE but not in
> firefox
> // msgHeadEl.onclick = function() {alert(''hello'');};
//This doesn''t work
> at all
> //msgHeadEl.onclick = "function()
{alert(''hello'');};" //neither does
> this
>
> On 12/18/05, Brian Peiris
<brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > sorry, I''ve fixed that already, still doesn''t work
> >
> >
> >
> > On 12/18/05, Tom Fakes
<Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> > >
> > >
> > >
> > > Oh yeh, I see it:
> > >
> > >
> > >
> > > var msgHeadEl =
document.getElementsByClassName("trash",
> newEvent);
> > >
> > >
> > >
> > > getElementsByClassName returns a collection, not a single
element.
> You need to set the onclick handler for each element in the collection.
> > >
> > >
> > >
> > > ________________________________
>
> > >
> > > From: Brian Peiris
[mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
> > > Sent: Sunday, December 18, 2005 8:00 PM
> > >
> > > To:
rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> > >
> > >
> > >
> > >
> > > Yes msgHeadEl is an img element, not a string, see Amol
Katdare''s
> first reply in this thread for more detailed code.
> > > Thanks,
> > > Brian Peiris
> > >
> > >
> > > On 12/18/05, Tom Fakes <
Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> > >
> > >
> > > I''m assuming here that msgHeadEl isn''t just the
ID of the element.
> If it is, then you need to do this:
> > >
> > > $(''msgHeadEl'').onclick = function() {new
Effect.Fade(...);};
> > >
> > > The $() function in Prototype will look up the ID in the DOM in a
> way that is compatible across browsers and return the element object you
> can then manipulate.
> > >
> > >
> > >
> > >
> > >
> > > ________________________________
>
> > >
> > > From:
rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>
[mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]
On Behalf Of
> Brian Peiris
> > > Sent: Sunday, December 18, 2005 7:08 PM
> > >
> > >
> > >
> > > To:
rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> > >
> > >
> > >
> > >
> > > Nope, still doesn''t work.
> > >
> > >
> > > On 12/18/05, Tom Fakes
<Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> > >
> > >
> > > This should work:
> > >
> > >
> > >
> > > msgHeadEl.onclick = function() {new Effect.Fade(...);};
> > >
> > >
> > >
> > > ________________________________
>
> > >
> > > From: Brian Peiris [mailto:
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
> > > Sent: Sunday, December 18, 2005 1:56 PM
> > >
> > >
> > >
> > > To:
rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> > >
> > >
> > >
> > >
> > > OK, I''ll try it out when I get a chance,
> > > One more thing, it seems
> > > msgHeadEl.onclick = "new Effect.Fade(...);";
> > > doesn''t work in firefox, only IE as far as
I''ve tested.
> > > can anyone suggest a solution?
> > > Thanks,
> > > Brian Peiris
> > >
> > >
> > > On 12/18/05, Tom Fakes
<Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> > >
> > >
> > > I have some code that that adds an Element.replace() method to
> Prototype. This uses outerHTML if it''s available and other DOM
magic on
> Firefox.
> > >
> > >
> > >
> > > I''ve sent this to Sam for possible inclusion in future
versions of
> Prototype.
> > >
> > >
> > >
> > >
> http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-bette
> r-replace-semantics
> > >
> > >
> > >
> > > ________________________________
>
> > >
> > > From: Thomas Fuchs [mailto:
t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org]
> > > Sent: Sunday, December 18, 2005 12:48 PM
> > > To:
rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> > >
> > >
> > >
> > >
> > >
> > > The outerHTML property is not available on all browsers (namely
not
> on Firefox).
> > >
> > >
> > > Stumbled upon this just today.
> > >
> > >
> > >
> > >
> > >
> > > -Thomas
> > >
> > >
> > >
> > >
> > >
> > > Am 18.12.2005 um 21:08 schrieb Amol Katdare:
> > >
> > >
> > >
> > > hmm...
> > > I have never used prototype''s Insertion functionality.
> > > But new Insertion.Before(theID, newEvent.outerHTML) should work.
> > >
> > >
> > > _______________________________________________
> > > Rails-spinoffs mailing list
> > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> > >
> > >
> > >
> > >
> > > --
> > > ===========================> > > Brian Peiris
> > > Brampton, Ontario, Canada
> > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > > ===========================> > >
> > >
> > > _______________________________________________
> > > Rails-spinoffs mailing list
> > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> > >
> > >
> > >
> > >
> > > --
> > > ===========================> > > Brian Peiris
> > > Brampton, Ontario, Canada
> > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > > ===========================> > >
> > >
> > > _______________________________________________
> > > Rails-spinoffs mailing list
> > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > ===========================> > > Brian Peiris
> > > Brampton, Ontario, Canada
> > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > > ===========================> > >
_______________________________________________
> > > Rails-spinoffs mailing list
> > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> > >
> > >
> > >
> >
> >
> >
> > --
> > ===========================> > Brian Peiris
> > Brampton, Ontario, Canada
> > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > ===========================>
>
>
> --
> ===========================> Brian Peiris
> Brampton, Ontario, Canada
> brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> ===========================>
_______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
============================
I see the problem. You are adding the handler to the cloned DOM, and
then getting the innerHTML. The innerHTML will not include the
''onclick'' code you added (although it looks like IE does make
this work
as you expect).
Instead of this:
new Insertion.Before("placeholder_event_div","<div
style=''background-color:lightblue;''>2"+newEvent.innerHTML+"<\/div>");
Try this:
$("placeholder_event_div").parentNode.insertBefore(newEvent,
$("placeholder_event_div"));
You''ll probably need to add this code before the insertBefore call to
make it show up:
newEvent.style.display = '''';
-----Original Message-----
From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]
On Behalf Of Brian
Peiris
Sent: Sunday, December 18, 2005 8:51 PM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: Re: [Rails-spinoffs] problems with quotes and escaping
Full test code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script src="js/prototype.js" type="text/javascript">
</script>
<script src="js/scriptaculous.js"
type="text/javascript">
</script>
<title></title>
</head>
<body>
<div style="background-color:lightblue;" id="bar">
1
<div class="data">
<img border="0" class="foo">
</div>
</div>
<div id="placeholder_event_div"
style="display:none;">
<div class="data">
<img border="0" class="foo">
</div>
</div>
<script type="text/javascript">
var newEvent $("placeholder_event_div").cloneNode(true);
var el = document.getElementsByClassName("foo",
newEvent)[0];
//el.onclick = "alert(''hello'')"; //This works in
IE but
not in firefox
el.onclick = function() {alert(''hello'');}; //This
doesn''t work at all
new Insertion.Before("placeholder_event_div","<div
style=''background-color:lightblue;''>2"+newEvent.innerHTML+"<\/div>");
</script>
</body>
</html>
On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org>
wrote:> I have almost the same code (simplified here) and it works for me:
>
> <div class="container" id="bar">
> <div class="data">
> <img border="0" class="foo"
... />
> </div>
> </div>
> <script>
> var el = document.getElementsByClassName("foo",
> $(''bar''))[0];
> el.onclick = function() { alert(''Hi''); };
> </script>
>
> Check the Firefox Javascript console to see if there are any errors
from> somewhere else in the code.
>
> -----Original Message-----
> From: Brian Peiris
[mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
> Sent: Sunday, December 18, 2005 8:17 PM
> To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Subject: Re: [Rails-spinoffs] problems with quotes and escaping
>
> Here''s my code:
> var msgHeadEl = document.getElementsByClassName("trash",
newEvent)[0];
> msgHeadEl.onclick = "alert(''hello'')"; //This
works in IE but not in
> firefox
> // msgHeadEl.onclick = function() {alert(''hello'');};
//This doesn''t
work> at all
> //msgHeadEl.onclick = "function()
{alert(''hello'');};" //neither does
> this
>
> On 12/18/05, Brian Peiris
<brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > sorry, I''ve fixed that already, still doesn''t work
> >
> >
> >
> > On 12/18/05, Tom Fakes
<Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> > >
> > >
> > >
> > > Oh yeh, I see it:
> > >
> > >
> > >
> > > var msgHeadEl =
document.getElementsByClassName("trash",
> newEvent);
> > >
> > >
> > >
> > > getElementsByClassName returns a collection, not a single
element.
> You need to set the onclick handler for each element in the
collection.> > >
> > >
> > >
> > > ________________________________
>
> > >
> > > From: Brian Peiris
[mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
> > > Sent: Sunday, December 18, 2005 8:00 PM
> > >
> > > To:
rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> > >
> > >
> > >
> > >
> > > Yes msgHeadEl is an img element, not a string, see Amol
Katdare''s
> first reply in this thread for more detailed code.
> > > Thanks,
> > > Brian Peiris
> > >
> > >
> > > On 12/18/05, Tom Fakes <
Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> > >
> > >
> > > I''m assuming here that msgHeadEl isn''t just the
ID of the element.
> If it is, then you need to do this:
> > >
> > > $(''msgHeadEl'').onclick = function() {new
Effect.Fade(...);};
> > >
> > > The $() function in Prototype will look up the ID in the DOM in a
> way that is compatible across browsers and return the element object
you> can then manipulate.
> > >
> > >
> > >
> > >
> > >
> > > ________________________________
>
> > >
> > > From:
rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>
[mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]
On Behalf Of
> Brian Peiris
> > > Sent: Sunday, December 18, 2005 7:08 PM
> > >
> > >
> > >
> > > To:
rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> > >
> > >
> > >
> > >
> > > Nope, still doesn''t work.
> > >
> > >
> > > On 12/18/05, Tom Fakes
<Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> > >
> > >
> > > This should work:
> > >
> > >
> > >
> > > msgHeadEl.onclick = function() {new Effect.Fade(...);};
> > >
> > >
> > >
> > > ________________________________
>
> > >
> > > From: Brian Peiris [mailto:
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
> > > Sent: Sunday, December 18, 2005 1:56 PM
> > >
> > >
> > >
> > > To:
rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> > >
> > >
> > >
> > >
> > > OK, I''ll try it out when I get a chance,
> > > One more thing, it seems
> > > msgHeadEl.onclick = "new Effect.Fade(...);";
> > > doesn''t work in firefox, only IE as far as
I''ve tested.
> > > can anyone suggest a solution?
> > > Thanks,
> > > Brian Peiris
> > >
> > >
> > > On 12/18/05, Tom Fakes
<Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:
> > >
> > >
> > > I have some code that that adds an Element.replace() method to
> Prototype. This uses outerHTML if it''s available and other DOM
magic
on> Firefox.
> > >
> > >
> > >
> > > I''ve sent this to Sam for possible inclusion in future
versions of
> Prototype.
> > >
> > >
> > >
> > >
>
http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-bette> r-replace-semantics
> > >
> > >
> > >
> > > ________________________________
>
> > >
> > > From: Thomas Fuchs [mailto:
t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org]
> > > Sent: Sunday, December 18, 2005 12:48 PM
> > > To:
rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping
> > >
> > >
> > >
> > >
> > >
> > > The outerHTML property is not available on all browsers (namely
not> on Firefox).
> > >
> > >
> > > Stumbled upon this just today.
> > >
> > >
> > >
> > >
> > >
> > > -Thomas
> > >
> > >
> > >
> > >
> > >
> > > Am 18.12.2005 um 21:08 schrieb Amol Katdare:
> > >
> > >
> > >
> > > hmm...
> > > I have never used prototype''s Insertion functionality.
> > > But new Insertion.Before(theID, newEvent.outerHTML) should work.
> > >
> > >
> > > _______________________________________________
> > > Rails-spinoffs mailing list
> > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> > >
> > >
> > >
> > >
> > > --
> > > ===========================> > > Brian Peiris
> > > Brampton, Ontario, Canada
> > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > > ===========================> > >
> > >
> > > _______________________________________________
> > > Rails-spinoffs mailing list
> > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> > >
> > >
> > >
> > >
> > > --
> > > ===========================> > > Brian Peiris
> > > Brampton, Ontario, Canada
> > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > > ===========================> > >
> > >
> > > _______________________________________________
> > > Rails-spinoffs mailing list
> > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > ===========================> > > Brian Peiris
> > > Brampton, Ontario, Canada
> > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > > ===========================> > >
_______________________________________________
> > > Rails-spinoffs mailing list
> > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> > >
> > >
> > >
> >
> >
> >
> > --
> > ===========================> > Brian Peiris
> > Brampton, Ontario, Canada
> > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> > ===========================>
>
>
> --
> ===========================> Brian Peiris
> Brampton, Ontario, Canada
> brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
> ===========================>
_______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
--
===========================Brian Peiris
Brampton, Ontario, Canada
brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
===========================_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Finally, it works! Thank you so much, that would have taken me ages! Just one last thing, is it possible to stick with Insertion.Before, just to keep things clean? If not I suggest we change Insertion so that it accepts DOM nodes instead of and HTML string, or both. On 12/19/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:> I see the problem. You are adding the handler to the cloned DOM, and > then getting the innerHTML. The innerHTML will not include the > ''onclick'' code you added (although it looks like IE does make this work > as you expect). > > Instead of this: > new Insertion.Before("placeholder_event_div","<div > style=''background-color:lightblue;''>2"+newEvent.innerHTML+"<\/div>"); > > Try this: > $("placeholder_event_div").parentNode.insertBefore(newEvent, > $("placeholder_event_div")); > > > You''ll probably need to add this code before the insertBefore call to > make it show up: > newEvent.style.display = ''''; > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Brian > Peiris > Sent: Sunday, December 18, 2005 8:51 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] problems with quotes and escaping > > Full test code: > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> > <html> > <head> > <script src="js/prototype.js" type="text/javascript"> > </script> > <script src="js/scriptaculous.js" type="text/javascript"> > </script> > <title></title> > </head> > <body> > <div style="background-color:lightblue;" id="bar"> > 1 > <div class="data"> > <img border="0" class="foo"> > </div> > </div> > <div id="placeholder_event_div" style="display:none;"> > <div class="data"> > <img border="0" class="foo"> > </div> > </div> > <script type="text/javascript"> > var newEvent > $("placeholder_event_div").cloneNode(true); > var el = document.getElementsByClassName("foo", > newEvent)[0]; > //el.onclick = "alert(''hello'')"; //This works in IE but > not in firefox > el.onclick = function() {alert(''hello'');}; //This > doesn''t work at all > new Insertion.Before("placeholder_event_div","<div > style=''background-color:lightblue;''>2"+newEvent.innerHTML+"<\/div>"); > </script> > </body> > </html> > > On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > I have almost the same code (simplified here) and it works for me: > > > > <div class="container" id="bar"> > > <div class="data"> > > <img border="0" class="foo" ... /> > > </div> > > </div> > > <script> > > var el = document.getElementsByClassName("foo", > > $(''bar''))[0]; > > el.onclick = function() { alert(''Hi''); }; > > </script> > > > > Check the Firefox Javascript console to see if there are any errors > from > > somewhere else in the code. > > > > -----Original Message----- > > From: Brian Peiris [mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > > Sent: Sunday, December 18, 2005 8:17 PM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping > > > > Here''s my code: > > var msgHeadEl = document.getElementsByClassName("trash", newEvent)[0]; > > msgHeadEl.onclick = "alert(''hello'')"; //This works in IE but not in > > firefox > > // msgHeadEl.onclick = function() {alert(''hello'');}; //This doesn''t > work > > at all > > //msgHeadEl.onclick = "function() {alert(''hello'');};" //neither does > > this > > > > On 12/18/05, Brian Peiris <brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > sorry, I''ve fixed that already, still doesn''t work > > > > > > > > > > > > On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > > > > > > > > > > > > > > > Oh yeh, I see it: > > > > > > > > > > > > > > > > var msgHeadEl = document.getElementsByClassName("trash", > > newEvent); > > > > > > > > > > > > > > > > getElementsByClassName returns a collection, not a single element. > > You need to set the onclick handler for each element in the > collection. > > > > > > > > > > > > > > > > ________________________________ > > > > > > > > > > From: Brian Peiris [mailto:brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > > > > Sent: Sunday, December 18, 2005 8:00 PM > > > > > > > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping > > > > > > > > > > > > > > > > > > > > Yes msgHeadEl is an img element, not a string, see Amol Katdare''s > > first reply in this thread for more detailed code. > > > > Thanks, > > > > Brian Peiris > > > > > > > > > > > > On 12/18/05, Tom Fakes < Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > > > > > > > > > > > I''m assuming here that msgHeadEl isn''t just the ID of the element. > > If it is, then you need to do this: > > > > > > > > $(''msgHeadEl'').onclick = function() {new Effect.Fade(...);}; > > > > > > > > The $() function in Prototype will look up the ID in the DOM in a > > way that is compatible across browsers and return the element object > you > > can then manipulate. > > > > > > > > > > > > > > > > > > > > > > > > ________________________________ > > > > > > > > > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of > > Brian Peiris > > > > Sent: Sunday, December 18, 2005 7:08 PM > > > > > > > > > > > > > > > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping > > > > > > > > > > > > > > > > > > > > Nope, still doesn''t work. > > > > > > > > > > > > On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > > > > > > > > > > > This should work: > > > > > > > > > > > > > > > > msgHeadEl.onclick = function() {new Effect.Fade(...);}; > > > > > > > > > > > > > > > > ________________________________ > > > > > > > > > > From: Brian Peiris [mailto: brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > > > > Sent: Sunday, December 18, 2005 1:56 PM > > > > > > > > > > > > > > > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping > > > > > > > > > > > > > > > > > > > > OK, I''ll try it out when I get a chance, > > > > One more thing, it seems > > > > msgHeadEl.onclick = "new Effect.Fade(...);"; > > > > doesn''t work in firefox, only IE as far as I''ve tested. > > > > can anyone suggest a solution? > > > > Thanks, > > > > Brian Peiris > > > > > > > > > > > > On 12/18/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > > > > > > > > > > > I have some code that that adds an Element.replace() method to > > Prototype. This uses outerHTML if it''s available and other DOM magic > on > > Firefox. > > > > > > > > > > > > > > > > I''ve sent this to Sam for possible inclusion in future versions of > > Prototype. > > > > > > > > > > > > > > > > > > > http://blog.craz8.com/articles/2005/12/15/rails-rjs-templates-need-bette > > r-replace-semantics > > > > > > > > > > > > > > > > ________________________________ > > > > > > > > > > From: Thomas Fuchs [mailto: t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org] > > > > Sent: Sunday, December 18, 2005 12:48 PM > > > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > Subject: Re: [Rails-spinoffs] problems with quotes and escaping > > > > > > > > > > > > > > > > > > > > > > > > The outerHTML property is not available on all browsers (namely > not > > on Firefox). > > > > > > > > > > > > Stumbled upon this just today. > > > > > > > > > > > > > > > > > > > > > > > > -Thomas > > > > > > > > > > > > > > > > > > > > > > > > Am 18.12.2005 um 21:08 schrieb Amol Katdare: > > > > > > > > > > > > > > > > hmm... > > > > I have never used prototype''s Insertion functionality. > > > > But new Insertion.Before(theID, newEvent.outerHTML) should work. > > > > > > > > > > > > _______________________________________________ > > > > Rails-spinoffs mailing list > > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > > > > > > > > -- > > > > ===========================> > > > Brian Peiris > > > > Brampton, Ontario, Canada > > > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > > > > ===========================> > > > > > > > > > > > _______________________________________________ > > > > Rails-spinoffs mailing list > > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > > > > > > > > -- > > > > ===========================> > > > Brian Peiris > > > > Brampton, Ontario, Canada > > > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > > > > ===========================> > > > > > > > > > > > _______________________________________________ > > > > Rails-spinoffs mailing list > > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > ===========================> > > > Brian Peiris > > > > Brampton, Ontario, Canada > > > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > > > > ===========================> > > > _______________________________________________ > > > > Rails-spinoffs mailing list > > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > > > > > > > > > > > > -- > > > ===========================> > > Brian Peiris > > > Brampton, Ontario, Canada > > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > > > ===========================> > > > > > > > -- > > ===========================> > Brian Peiris > > Brampton, Ontario, Canada > > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > > ===========================> > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > -- > ===========================> Brian Peiris > Brampton, Ontario, Canada > brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > ===========================> _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- ===========================Brian Peiris Brampton, Ontario, Canada brianpeiris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or brianpeiris-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org ============================