List Info

Thread: How to assign a variable as value to a property




How to assign a variable as value to a property
user name
2008-01-03 07:27:02
$(element).setStyle({
  background: 'url(/image.gif) no-repeat'       /*
Myproblem:
background: 'someVariable' */
});

The above code snippet assigns the value 'url(image.gif)
no-repeat' to
the property 'background'. I have a situation where in i am
getting
the value i.e image URL from the back-end dynamically and i
am able to
store it in a variable say 'someVariable'. Now what is the
syntax I
should follow to assign 'someVariable' to background. Please
help.
--~--~---------~--~----~------------~-------~--~----~
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-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: How to assign a variable as value to a property
user name
2008-01-03 08:06:39
var bg = 'background: url(' + someVariable + ')
no-repeat;';
$(element).setStyle(bg);

that should do the trick.

On Jan 3, 2:27 pm, yash <itsme.y...gmail.com> wrote:
> $(element).setStyle({
>   background: 'url(/image.gif) no-repeat'       /*
Myproblem:
> background: 'someVariable' */
>
> });
>
> The above code snippet assigns the value
'url(image.gif) no-repeat' to
> the property 'background'. I have a situation where in
i am getting
> the value i.e image URL from the back-end dynamically
and i am able to
> store it in a variable say 'someVariable'. Now what is
the syntax I
> should follow to assign 'someVariable' to background.
Please help.
--~--~---------~--~----~------------~-------~--~----~
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-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: How to assign a variable as value to a property
user name
2008-01-03 08:32:08
Thanks for the reply.
The var bg is getting constructed correctly but $
(element).setStyle(bg); does not work.
Is there any particular way of accessing variables??


On Jan 3, 7:06 pm, "bram.vanders...gmail.com"
<bram.vanders...gmail.com> wrote:
> var bg = 'background: url(' + someVariable + ')
no-repeat;';
> $(element).setStyle(bg);
>
> that should do the trick.
>
> On Jan 3, 2:27 pm, yash <itsme.y...gmail.com> wrote:
>
> > $(element).setStyle({
> >   background: 'url(/image.gif) no-repeat'       /*
Myproblem:
> > background: 'someVariable' */
>
> > });
>
> > The above code snippet assigns the value
'url(image.gif) no-repeat' to
> > the property 'background'. I have a situation
where in i am getting
> > the value i.e image URL from the back-end
dynamically and i am able to
> > store it in a variable say 'someVariable'. Now
what is the syntax I
> > should follow to assign 'someVariable' to
background. Please help.
--~--~---------~--~----~------------~-------~--~----~
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-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )