Using icon to start onclick - Post ID...

User 122279 Photo


Senior Advisor
14,454 posts

Frank, I was just looking at that very thing and have made this wee file that I have attached. Don't know if this is what Jim is looking for.
Attachments:
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 379556 Photo


Registered User
1,535 posts

It seems good to me. Custom Attribute in SD V3 looks to be the way to use onclick.

Frank
User 2531231 Photo


Registered User
19 posts

Thanx Inger, Frank,
I tried something like Inger's Custom attribute and couldn't make it work, but I'll try again.
Who knows, I might have left out a semicolon or something.
Jim Baker
User 244626 Photo


Registered User
811 posts

Jim wrote:
Thanx Inger, Frank,
I tried something like Inger's Custom attribute and couldn't make it work, but I'll try again.
Who knows, I might have left out a semicolon or something.
Jim Baker


You can just use a icon and then target the id of the icon with jquery.


<script>

$("#myicon").click( function()
{
alert('icon clicked');
}
);
</script>



Attachments:
Bootstrap 5 CSS Grid.
User 122279 Photo


Senior Advisor
14,454 posts

Yeah, that is another variation, Easy, because there is no attribute.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 2531231 Photo


Registered User
19 posts

And also thanks Twinstream,
I knew I liked this forum - it'll keep my 80+ year old brain working.
I've never used jquery so tomorrow I will.
Jim Baker
User 379556 Photo


Registered User
1,535 posts

Jim wrote:

I tried something like Inger's Custom attribute and couldn't make it work


One thing to watch is that the Value of the Custom Attribute actually gets into the HTML when using 'Preview on ...'. I once failed to click outside the Value box before looking at the preview, and found that the source code of the preview showed onclick="".

Frank
User 2531231 Photo


Registered User
19 posts

Thank you so much for all the help.
I finally got it working using the Custom Attribute = onclick and value = myFunction(1 or -1).
One thing I was doing which now seems wrong, was using an Icon-link as the trigger.
This brought up the href window in SD3.
When I just used an icon the Custom Attribute route worked easily.
Anyway, I'm happy now with this thing.

Jim
User 244626 Photo


Registered User
811 posts

You can use the Icon-link also as a trigger however you would want to put "javascript:void(0);" in the href. and then add Ingers custom attribute.
Bootstrap 5 CSS Grid.
User 122279 Photo


Senior Advisor
14,454 posts

Travelling just now, so I can’t check, but I think I used icon link with nothing in the href.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com



Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.