Icon change after mouse click |
Post Reply |
Author | |
djju1029
Senior Member Joined: Aug 02 2016 Location: the US Status: Offline Points: 126 |
Post Options
Thanks(0)
Posted: Jan 17 2017 at 2:43pm |
Hi! OE Team,
I am implementing the feature that (for example): 1. User click a lock icon (current status is unlock.) 2. all text box are changed to "Read-only" 3. After that a lock icon is changed to "unlock icon" automatically. Unlock process is just toggle. OpenElement has a feature when mouse is hovering on icon, icon is changed to other picture. But I have difficulty that how I can change the icon after clicking. Do you have any idea to implement this feature? Thank you so much! DJ
|
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(1)
|
Hi,
It's better to code this manually. Add a Custom Class "button-lock" to your element (whatever it is - just not the Image Link with images already specified, to avoid conflicts, and not the Image either). Add a Custom Class "cb-lock" to all checkboxes to affect, Add a Code Block Source type CSS: .button-lock { background: center center no-repeat; background-size: contain; } .button-lock, .button-lock.locked:hover { background-image: url(Files/Other/my-images/unlocked.jpg); } .button-lock.locked, .button-lock:not(.locked):hover { background-image: url(Files/Other/my-images/locked.jpg); } Of course add corresponding images to Files/Other (to make sure they upload automatically) and modify URLs as needed. Then add a Code Block Source type Javascript:
|
|
djju1029
Senior Member Joined: Aug 02 2016 Location: the US Status: Offline Points: 126 |
Post Options
Thanks(0)
|
Thanks DmitOE, I learned the usage of .hasClass() & .toggleClass() from your code.
I put !isLocked instead of ('readonly', isLocked); Because, at first to toggle the class, it works when click twice. I am coding the icon changing now...but it looks not easy...
Edited by djju1029 - Jan 24 2017 at 5:09pm |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |