Changing button text on the fly?

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

Changing button text on the fly?

Brian Brown-2
Hello all,

I am attempting to change the text of a button when it is clicked and  
execute a callback. I've been trying to  use the html updater from an  
onClick: event, but this seems to be going in the wrong direction.

I would like this to happen without submitting a form, but just use  
the ajax callback. I think a similar technique would be useful for  
swapping out images on an image button for the click, hover, and  
normal states.

Has anyone done something like this? I've done it with pure  
javascript arrays and such, but that is no fun :-)


thanks!

- Brian

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

Re: Changing button text on the fly?

Lukas Renggli
> I would like this to happen without submitting a form, but just use
> the ajax callback.

html element id: 'theButton'; access: 'value'; assign: 'New Text'

> I think a similar technique would be useful for
> swapping out images on an image button for the click, hover, and
> normal states.

html effect id: 'altesBild'; hide
html effect id: 'neuesBild'; show

Lukas

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

Re: Changing button text on the fly?

Brian Brown-2

On Sep 18, 2007, at 12:42 AM, Lukas Renggli wrote:

>> I would like this to happen without submitting a form, but just use
>> the ajax callback.
>
> html element id: 'theButton'; access: 'value'; assign: 'New Text'

Thanks for responding Lukas. This works great for a input type=submit  
style, but not for a <button></button> tag. Do you have any idea what  
attribute I would access to change the content? 'value' doesn't do  
it, nor does 'text'.


>
>> I think a similar technique would be useful for
>> swapping out images on an image button for the click, hover, and
>> normal states.
>
> html effect id: 'altesBild'; hide
> html effect id: 'neuesBild'; show
>

Great!  Thank you.

> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

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

RE: Changing button text on the fly?

Ramon Leon-5
> On Sep 18, 2007, at 12:42 AM, Lukas Renggli wrote:
>
> >> I would like this to happen without submitting a form, but
> just use
> >> the ajax callback.
> >
> > html element id: 'theButton'; access: 'value'; assign: 'New Text'
>
> Thanks for responding Lukas. This works great for a input
> type=submit style, but not for a <button></button> tag. Do
> you have any idea what attribute I would access to change the
> content? 'value' doesn't do it, nor does 'text'.

Let's not forget that all of the event handlers take ordinary JavaScript.
You can easily say

onClick: 'this.innerText = "BlaBla"'

All that fancy scriptaculous stuff in Smalltalk just generates JavaScript
strings, so don't get stuck trying to figure out how to express everything
in Smalltalk.  Sure, it's nice, but sometimes you just need to drop into
JavaScript and do what you need to do.

Ramon Leon
http://onsmalltalk.com

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

Re: Changing button text on the fly?

Lukas Renggli
In reply to this post by Brian Brown-2
> >> I would like this to happen without submitting a form, but just use
> >> the ajax callback.
> >
> > html element id: 'theButton'; access: 'value'; assign: 'New Text'
>
> Thanks for responding Lukas. This works great for a input type=submit
> style, but not for a <button></button> tag. Do you have any idea what
> attribute I would access to change the content? 'value' doesn't do
> it, nor does 'text'.

html element id: 'theButton'; update: 'New Text'

Lukas

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

RE: Changing button text on the fly?

Ramon Leon-5
> html element id: 'theButton'; update: 'New Text'
>
> Lukas

Nice, but my point still stands, don't fear the JavaScript, once can't
always wait for Lukas to wrap everything (though often you can).

Ramon Leon
http://onsmalltalk.com

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

Re: Changing button text on the fly?

Brian Brown-2

On Sep 18, 2007, at 11:01 AM, Ramon Leon wrote:

>> html element id: 'theButton'; update: 'New Text'
>>
>> Lukas
>
> Nice, but my point still stands, don't fear the JavaScript, once can't
> always wait for Lukas to wrap everything (though often you can).

:-) Very true.

All of the suggestions in this thread worked well - my problem was  
that I was trying to do more than on thing in the onClick without  
using html evalutator. Now that I did that, everything is working great.

Also, I didn't have to write any actual JavaScript ;)

Thanks Lukas & Ramon

- Brian




>
> Ramon Leon
> http://onsmalltalk.com
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

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