Hi, I''ve found that in IE setStyle() doesn''t work if element
is not in
DOM yet.
E.g. this code
...
//I''m creating div through Builder.node();
var pos = this.field.cumulativeOffset();
div.setStyle({
	left: pos[0] + ''px'',
	top: ( pos[1] + this.field.offsetHeight ) + ''px'',
	width : ( Prototype.Browser.IE ) ? (this.field.offsetWidth +
''px'') :
(this.field.offsetWidth - 2 + ''px'')
});
document.getElementsByTagName("body")[0].appendChild(div);
works everywhere (Firefox, Opera, even Safari) except IE 7. Haven''t
tried in IE 6 yet. But I guess it would give the same result.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Hi, I''ve found that in IE setStyle() doesn''t work if element
is not in
DOM yet.
E.g. this code
...
//I''m creating div through Builder.node();
var pos = this.field.cumulativeOffset();
div.setStyle({
	left: pos[0] + ''px'',
	top: ( pos[1] + this.field.offsetHeight ) + ''px'',
	width : ( Prototype.Browser.IE ) ? (this.field.offsetWidth +
''px'') :
(this.field.offsetWidth - 2 + ''px'')
});
document.getElementsByTagName("body")[0].appendChild(div);
works everywhere (Firefox, Opera, even Safari) except IE 7. Haven''t
tried in IE 6 yet. But I guess it would give the same result.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
set an observer to monitor onload and then do it there.. there are loads of examples of onload watches in the list history. On Feb 8, 2008 9:17 AM, Rauan Maemirov <rauan1987-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, I''ve found that in IE setStyle() doesn''t work if element is not in > DOM yet. > > E.g. this code > > ... > //I''m creating div through Builder.node(); > > var pos = this.field.cumulativeOffset(); > > div.setStyle({ > left: pos[0] + ''px'', > top: ( pos[1] + this.field.offsetHeight ) + ''px'', > width : ( Prototype.Browser.IE ) ? (this.field.offsetWidth + ''px'') > : > (this.field.offsetWidth - 2 + ''px'') > }); > > document.getElementsByTagName("body")[0].appendChild(div); > > > works everywhere (Firefox, Opera, even Safari) except IE 7. Haven''t > tried in IE 6 yet. But I guess it would give the same result. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yeah, that''s would be right. But I''m adding new elements in js- scripts. So, there''s no difference. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can always go back to the basics and say element.style.left = "200px"; Or you could just omit IE users, i think thats the better approach ;-) On Feb 8, 11:47 am, Rauan Maemirov <rauan1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yeah, that''s would be right. But I''m adding new elements in js- > scripts. So, there''s no difference.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I have also run into similar troubles with IE. I would like to do
something like:
var myDiv = document.createElement("div");
div.setStyle({backgroundColor:''#000000''});
However, the above code produces an error in ie7 ("object doesn''t
support this property or method.")
I *can* get it to work using Element.setStyle(div, {...}), but does
anyone know why the former doesn''t work,
or how I could get it to work? You mentioned above setting an event
handler for onLoad. The above
occurs after the document has loaded and onLoad has been fired so I
don''t think that will help.
Any advice would be greatly appreciated,
Thanks!
Keith
On Feb 8, 2:53 pm, Matt Foster
<mattfoste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> You can always go back to the basics and say
>
> element.style.left = "200px";
>
> Or you could just omit IE users, i think thats the better
> approach  ;-)
>
> On Feb 8, 11:47 am, Rauan Maemirov
<rauan1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > Yeah, that''s would be right. But I''m adding new
elements in js-
> > scripts. So, there''s no difference.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Have a look at this: http://prototypejs.org/learn/extensions Should help you solve your problem. Best, Tobie On Feb 15, 9:33 pm, pwnedd <keith.hugh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have also run into similar troubles with IE. I would like to do > something like: > > var myDiv = document.createElement("div"); > div.setStyle({backgroundColor:''#000000''}); > > However, the above code produces an error in ie7 ("object doesn''t > support this property or method.") > > I *can* get it to work using Element.setStyle(div, {...}), but does > anyone know why the former doesn''t work, > or how I could get it to work? You mentioned above setting an event > handler for onLoad. The above > occurs after the document has loaded and onLoad has been fired so I > don''t think that will help. > > Any advice would be greatly appreciated, > > Thanks! > Keith > > On Feb 8, 2:53 pm, Matt Foster <mattfoste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > You can always go back to the basics and say > > > element.style.left = "200px"; > > > Or you could just omit IE users, i think thats the better > > approach ;-) > > > On Feb 8, 11:47 am, Rauan Maemirov <rauan1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Yeah, that''s would be right. But I''m adding new elements in js- > > > scripts. So, there''s no difference.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Tobie, That was really helpful :) The Element functionality now works fine in ie if I use either the "Element.function(myElement)" syntax, or use Element.extend(myElement); prior to calling the function. In case anyone is interested, the problem is more general than just affecting setStyle. I also ran into similar issues when using hide() under certain contexts. Here are two of the cases where the functions would not cooperate in ie7 on windows: 1. Calling element.setStyle on an element after creating it using document.createElement (see above). 2. Calling element.hide() on an object instance variable (e.g. this.myVariable.hide()). -Keith On Feb 15, 3:45 pm, Tobie Langel <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Have a look at this:http://prototypejs.org/learn/extensions > > Should help you solve your problem. > > Best, > > Tobie > > On Feb 15, 9:33 pm, pwnedd <keith.hugh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have also run into similar troubles with IE. I would like to do > > something like: > > > var myDiv = document.createElement("div"); > > div.setStyle({backgroundColor:''#000000''}); > > > However, the above code produces an error in ie7 ("object doesn''t > > support this property or method.") > > > I *can* get it to work using Element.setStyle(div, {...}), but does > > anyone know why the former doesn''t work, > > or how I could get it to work? You mentioned above setting an event > > handler for onLoad. The above > > occurs after the document has loaded and onLoad has been fired so I > > don''t think that will help. > > > Any advice would be greatly appreciated, > > > Thanks! > > Keith > > > On Feb 8, 2:53 pm, Matt Foster <mattfoste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > You can always go back to the basics and say > > > > element.style.left = "200px"; > > > > Or you could just omit IE users, i think thats the better > > > approach ;-) > > > > On Feb 8, 11:47 am, Rauan Maemirov <rauan1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Yeah, that''s would be right. But I''m adding new elements in js- > > > > scripts. So, there''s no difference.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
To clarify:
$() extends elemets for you and so does every other DOM related
methods in Prototype.
using "new Element(''div'', {attributes...})" instead
of
"document.createElement(''div'')" also solves that
problem.
when you store an element inside of a class, do this:
this.element = $(element);
like that you''re keeping a reference to the extended element.
Best,
Tobie
On Feb 15, 10:21 pm, pwnedd
<keith.hugh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Thanks Tobie,
>
> That was really helpful :) The Element functionality now works fine in
> ie
> if I use either the "Element.function(myElement)" syntax, or use
> Element.extend(myElement); prior
> to calling the function.
>
> In case anyone is interested, the problem is more general than just
> affecting setStyle. I also
> ran into similar issues when using hide() under certain contexts. Here
> are two of the cases
> where the functions would not cooperate in ie7 on windows:
>
> 1. Calling element.setStyle on an element after creating it using
> document.createElement (see above).
> 2. Calling element.hide() on an object instance variable (e.g.
> this.myVariable.hide()).
>
> -Keith
>
> On Feb 15, 3:45 pm, Tobie Langel
<tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > Have a look at this:http://prototypejs.org/learn/extensions
>
> > Should help you solve your problem.
>
> > Best,
>
> > Tobie
>
> > On Feb 15, 9:33 pm, pwnedd
<keith.hugh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > I have also run into similar troubles with IE. I would like to do
> > > something like:
>
> > > var myDiv = document.createElement("div");
> > > div.setStyle({backgroundColor:''#000000''});
>
> > > However, the above code produces an error in ie7 ("object
doesn''t
> > > support this property or method.")
>
> > > I *can* get it to work using Element.setStyle(div, {...}), but
does
> > > anyone know why the former doesn''t work,
> > > or how I could get it to work? You mentioned above setting an
event
> > > handler for onLoad. The above
> > > occurs after the document has loaded and onLoad has been fired so
I
> > > don''t think that will help.
>
> > > Any advice would be greatly appreciated,
>
> > > Thanks!
> > > Keith
>
> > > On Feb 8, 2:53 pm, Matt Foster
<mattfoste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > You can always go back to the basics and say
>
> > > > element.style.left = "200px";
>
> > > > Or you could just omit IE users, i think thats the better
> > > > approach  ;-)
>
> > > > On Feb 8, 11:47 am, Rauan Maemirov
<rauan1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > Yeah, that''s would be right. But I''m
adding new elements in js-
> > > > > scripts. So, there''s no difference.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Thanks Tobie, So what would you say would be the best style to use? keith On Feb 15, 4:39 pm, Tobie Langel <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> To clarify: > > $() extends elemets for you and so does every other DOM related > methods in Prototype. > > using "new Element(''div'', {attributes...})" instead of > "document.createElement(''div'')" also solves that problem. > > when you store an element inside of a class, do this: > > this.element = $(element); > > like that you''re keeping a reference to the extended element. > > Best, > > Tobie > > On Feb 15, 10:21 pm, pwnedd <keith.hugh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Thanks Tobie, > > > That was really helpful :) The Element functionality now works fine in > > ie > > if I use either the "Element.function(myElement)" syntax, or use > > Element.extend(myElement); prior > > to calling the function. > > > In case anyone is interested, the problem is more general than just > > affecting setStyle. I also > > ran into similar issues when using hide() under certain contexts. Here > > are two of the cases > > where the functions would not cooperate in ie7 on windows: > > > 1. Calling element.setStyle on an element after creating it using > > document.createElement (see above). > > 2. Calling element.hide() on an object instance variable (e.g. > > this.myVariable.hide()). > > > -Keith > > > On Feb 15, 3:45 pm, Tobie Langel <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Have a look at this:http://prototypejs.org/learn/extensions > > > > Should help you solve your problem. > > > > Best, > > > > Tobie > > > > On Feb 15, 9:33 pm, pwnedd <keith.hugh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I have also run into similar troubles with IE. I would like to do > > > > something like: > > > > > var myDiv = document.createElement("div"); > > > > div.setStyle({backgroundColor:''#000000''}); > > > > > However, the above code produces an error in ie7 ("object doesn''t > > > > support this property or method.") > > > > > I *can* get it to work using Element.setStyle(div, {...}), but does > > > > anyone know why the former doesn''t work, > > > > or how I could get it to work? You mentioned above setting an event > > > > handler for onLoad. The above > > > > occurs after the document has loaded and onLoad has been fired so I > > > > don''t think that will help. > > > > > Any advice would be greatly appreciated, > > > > > Thanks! > > > > Keith > > > > > On Feb 8, 2:53 pm, Matt Foster <mattfoste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > You can always go back to the basics and say > > > > > > element.style.left = "200px"; > > > > > > Or you could just omit IE users, i think thats the better > > > > > approach ;-) > > > > > > On Feb 8, 11:47 am, Rauan Maemirov <rauan1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Yeah, that''s would be right. But I''m adding new elements in js- > > > > > > scripts. So, there''s no difference.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---