I''m trying to alter the left margin of a DIV. The page loads withe the left margin set at 160px, and I want to set it to 0px. This is supposed to occur when the user clicks a link to hide another DIV, so the space is filled, but the DIV won''t resize. No javascript errors are returned, and the rest of the code works fine. Any ideas why I can get my DIV to resize by changing the marginLeft? Cheers --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
from http://prototypejs.org/api/element/setStyle Not all CSS shorthand properties are supported. You may only use the CSS properties described in the Document Object Model (DOM) Level 2 Style Specification<http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-ElementCSSInlineStyle> . could that be the problem? On 10/23/07, MatBeard <mat.j.beard-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > I''m trying to alter the left margin of a DIV. The page loads withe the > left margin set at 160px, and I want to set it to 0px. > > This is supposed to occur when the user clicks a link to hide another > DIV, so the space is filled, but the DIV won''t resize. > > No javascript errors are returned, and the rest of the code works > fine. Any ideas why I can get my DIV to resize by changing the > marginLeft? > > Cheers > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 24, 1:50 am, MatBeard <mat.j.be...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> I''m trying to alter the left margin of a DIV. The page loads withe the > left margin set at 160px, and I want to set it to 0px. > > This is supposed to occur when the user clicks a link to hide another > DIV, so the space is filled, but the DIV won''t resize. > > No javascript errors are returned, and the rest of the code works > fine. Any ideas why I can get my DIV to resize by changing the > marginLeft? > > Cheers--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 24, 1:50 am, MatBeard <mat.j.be...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> I''m trying to alter the left margin of a DIV. The page loads withe the > left margin set at 160px, and I want to set it to 0px. > > This is supposed to occur when the user clicks a link to hide another > DIV, so the space is filled, but the DIV won''t resize. > > No javascript errors are returned, and the rest of the code works > fine. Any ideas why I can get my DIV to resize by changing the > marginLeft?Dunno, the following works fine for me: <div id="d0" style="border: 1px solid red; margin-left: 160px;"> <button onclick="$(''d0'').style.marginLeft = 0;">Set margin</button> </div> -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hmm, That works for me too, but I was trying to use $ (''div'').setStyle({''marginLeft: 0''}); Is that not the way to use setStyle? What am I missing? Cheers, Mat On Oct 24, 3:39 am, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> On Oct 24, 1:50 am, MatBeard <mat.j.be...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > I''m trying to alter the left margin of a DIV. The page loads withe the > > left margin set at 160px, and I want to set it to 0px. > > > This is supposed to occur when the user clicks a link to hide another > > DIV, so the space is filled, but the DIV won''t resize. > > > No javascript errors are returned, and the rest of the code works > > fine. Any ideas why I can get my DIV to resize by changing the > > marginLeft? > > Dunno, the following works fine for me: > > <div id="d0" style="border: 1px solid red; margin-left: 160px;"> > <button onclick="$(''d0'').style.marginLeft = 0;">Set margin</button> > </div> > > -- > Rob--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Try it like this... $(''div'').setStyle({ ''marginLeft'' : ''0px'' }); You have to treat as an Hash... On Oct 24, 9:56 am, MatBeard <mat.j.be...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hmm, > > That works for me too, but I was trying to use $ > (''div'').setStyle({''marginLeft: 0''}); > > Is that not the way to use setStyle? What am I missing? > > Cheers, > > Mat > > On Oct 24, 3:39 am, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote: > > > On Oct 24, 1:50 am, MatBeard <mat.j.be...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > I''m trying to alter the left margin of a DIV. The page loads withe the > > > left margin set at 160px, and I want to set it to 0px. > > > > This is supposed to occur when the user clicks a link to hide another > > > DIV, so the space is filled, but the DIV won''t resize. > > > > No javascript errors are returned, and the rest of the code works > > > fine. Any ideas why I can get my DIV to resize by changing the > > > marginLeft? > > > Dunno, the following works fine for me: > > > <div id="d0" style="border: 1px solid red; margin-left: 160px;"> > > <button onclick="$(''d0'').style.marginLeft = 0;">Set margin</button> > > </div> > > > -- > > Rob--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
That''s done it. Thanks very much. On Oct 24, 11:59 am, Wizz <woutaw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try it like this... > > $(''div'').setStyle({ > ''marginLeft'' : ''0px'' > > }); > > You have to treat as an Hash... > > On Oct 24, 9:56 am, MatBeard <mat.j.be...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > Hmm, > > > That works for me too, but I was trying to use $ > > (''div'').setStyle({''marginLeft: 0''}); > > > Is that not the way to use setStyle? What am I missing? > > > Cheers, > > > Mat > > > On Oct 24, 3:39 am, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote: > > > > On Oct 24, 1:50 am, MatBeard <mat.j.be...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > I''m trying to alter the left margin of a DIV. The page loads withe the > > > > left margin set at 160px, and I want to set it to 0px. > > > > > This is supposed to occur when the user clicks a link to hide another > > > > DIV, so the space is filled, but the DIV won''t resize. > > > > > No javascript errors are returned, and the rest of the code works > > > > fine. Any ideas why I can get my DIV to resize by changing the > > > > marginLeft? > > > > Dunno, the following works fine for me: > > > > <div id="d0" style="border: 1px solid red; margin-left: 160px;"> > > > <button onclick="$(''d0'').style.marginLeft = 0;">Set margin</button> > > > </div> > > > > -- > > > Rob- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---