style CSS and liveCallback

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

style CSS and liveCallback

Burella Juan M.
Hi all,
      I have a liveCallback on a select tag. When any element  is selected on this tag, I want change Style. I noticed when I perform a submission of the form, the #style method is called, so CSS is applied, but when I used liveCallbak, that doesn't happen.
How could I update the CSS code when I'm using liveCallback?
I am working with  Seaside2.5b8-mb.15/Squeak3.7.

Thanks in advance.


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: style CSS and liveCallback

Michel Bany-3

>       I have a liveCallback on a select tag. When any element  is
> selected on this tag, I want change Style. I noticed when I perform a
> submission of the form, the #style method is called, so CSS is
> applied, but when I used liveCallbak, that doesn't happen.
> How could I update the CSS code when I'm using liveCallback?
> I am working with  Seaside2.5b8-mb.15/Squeak3.7.
>
The #style methods are not called during execution of  live callbacks.
Even if they were, their corresponding values would not be used,
since the live callback Javascript does not handle the html head
elements. Processing them, i.e. download the stylesheets and apply
the styles would be quite a challenge.

There might be a way though, to achieve what you are looking for.
The code below is written using the email editor, therefore untested

1) Add new methods to your component

renderStyleOn: html
    html attributes id: 'live-styles'.
    html tag: 'style' do: self liveStyle.

liveStyle
    ^ whatever styles need to be changed by live callbacks

2) Call the first method from your rendering method, must be at the end.

3) Call it also from your live callbacks. The live callback Javascript will
live-update the style element.

4) Pray for the browser to update the styles when the style element is
live-updated. Some browsers may, some other may not.

HTH,
Michel.






_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: style CSS and liveCallback

Avi  Bryant

On Apr 10, 2006, at 10:48 PM, Michel Bany wrote:

>
>>       I have a liveCallback on a select tag. When any element  is  
>> selected on this tag, I want change Style. I noticed when I  
>> perform a submission of the form, the #style method is called, so  
>> CSS is applied, but when I used liveCallbak, that doesn't happen.
>> How could I update the CSS code when I'm using liveCallback?
>> I am working with  Seaside2.5b8-mb.15/Squeak3.7.
>>
> The #style methods are not called during execution of  live callbacks.
> Even if they were, their corresponding values would not be used,
> since the live callback Javascript does not handle the html head
> elements. Processing them, i.e. download the stylesheets and apply
> the styles would be quite a challenge.

Never update CSS styles dynamically.  A #style method should always  
just return a literal string.  Instead, add different CSS classes for  
each of the possible styles you'll want, have permanent CSS entries  
that define styles for these classes, and change the class of your  
element dynamically when you want it to change its look.

Avi
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: style CSS and liveCallback

Michel Bany

On 11 Apr 2006, at 08:21 , Avi Bryant wrote:

> Never update CSS styles dynamically.  A #style method should always  
> just return a literal string.  Instead, add different CSS classes  
> for each of the possible styles you'll want, have permanent CSS  
> entries that define styles for these classes, and change the class  
> of your element dynamically when you want it to change its look.

Agreed, but as a curious person, I gave it a try and I included live-
updated style elements in an html.

This gives you an idea about how smart the various browsers are :
1) In Firefox (the clear winner), when a style element is live-
updated, the new style is immediately applied.
2) In Safari, the Javascript gets an exception when you try to live-
update a style element.
You need to catch it, if you want to update the rest of the live-
updated elements.
3) In IE, live updates of style elements are silently ignored and the  
rest of the live-updated elements are updated.

So I published  SeasideAsync-mb.38 that includes the try/catch in the  
Javascript.

Michel.
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside