1

How can I make a button change its image by clicking on the same button?

asked 2018-04-09 10:02:44 +0800

elanyerth gravatar image elanyerth
13 2

updated 2018-04-10 12:43:21 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

How can I make a button change its image by clicking on the same button?

<zk>
    <window >
        <button id="boton" image="/imagen/likecora.png" label="change color" onClick='Clients.evalJavaScript("cambiar()")' >
            <attribute name="onClick"><![CDATA[ boton.setImageContent("/imagen/likerojo.png");]]>
            </attribute>
         </button>
    </window>
</zk>
delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-04-10 12:49:07 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

I don't know if you saw it, but you set the image attribute in the button and try to adapt the imageContent attribute with your javascript.
Just make boton.setImageContent( to boton.setImage(

Chill.

link publish delete flag offensive edit
0

answered 2018-04-10 15:33:35 +0800

cor3000 gravatar image cor3000
6280 2 7

Chill is right about using setImage() in case you want to update the png url.

An alternative using css styles with fontawesome icons is to update the iconSclass as in this zk fiddle

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2018-04-09 10:02:44 +0800

Seen: 9 times

Last updated: Apr 10 '18

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More