How do I execute embeded jQuery via a button?

Hi duncan – or someone else of the Sparkle community,

do you know how to execute (trigger) a corresponding “jQuery script” via a button in a Sparkle website (webpage)?

I think I know how to embed jQuery into a Sparkle website (webpage) but I could not find out what to write into the buttons “on-click-external-website-field” to make the button execute the “jQuery script” – although I know how to embed and execute pure javascript via a button.

I hope I was able to clarify my problem and would very much appreciate a “simple” :wink: solution – if there is one at all.

Have a nice day!

A button cannot be assigned to trigger a jquery script currently, and I’m 90% certain of this.

It would be a really useful feature to have, because I have be pondering this the last few days!


Hi Scott,

thanks for your immediate answer. I’m sure you tested/researched as much as I did and a “10% chance” is definitely not much … But maybe there is someone out there … :alien:


We just need to call out to the universe and it will answer! :grinning:

Scripts, by their very nature, are usually loaded when the web page loads. This makes any action required by the script available to any element on the page. If your script specifically requires a button click to perform a specific task, then that function will have to be coded into the page somehow. It may be a little more enlightening if we could know what the button click is supposed to do in relation to the script.

Thanks for your replying. I know that scripts are loaded with the page. And of course the script’s function must be encoded into the page – which I have done successfully with Sparkles “embed feature” using javascript, CSS …

I’m looking for the right command to trigger a function in jQuery that needs a buttton, if that is possible at all. As I wrote earlier: It is possible with javascript but i want to know how to use the precoded jQuery scripts.


“It may be a little more enlightening if we could know what the button click is supposed to do in relation to the script.”

Any jQuery script that requires a button and there are a lot – you name it. :grinning:

Yes, I agree. There are limitless functions that are triggered by page elements. This is why I suggest that the code (including its trigger element itself) has to be coded into the page. In the absence of custom attributes, this means creating the button and its onclick event as a peice of code which you enter into your sparkle page through the code embedding option. For example, instead of adding the button to the page and then assigning attributes to it, you will have to add an embed box to the page and place some code that creates the button and its function. Here is a simple example:

<button onclick="myFunction()">Click me</button>

This will create a button with the text “Click me” as its label and when clicked it will execute a function named “myFunction” The function itself will also be defined in the code between script tags.

If you want to style the button, you will have to create inline styling elements between style tags and add that to the code.

That definitely is a “workaround” – thanks for that! Still hoping that there is a way to work with buttons directly styled in Sparkle.

And waiting for the Sparkle team to answer that topic.:grinning: Sparkle seems to also use jQuery for some integrated scripts.

Sorry I’ll just restate what I said in other threads. There are many tools for coders, we prefer focusing on visual solutions for “the rest of us”.

Also I’d suggest assuming nothing about the code Sparkle generates.


What a helpful answer to a paying customer!

I’m sorry for your disappointment. But just to be clear, we are 100% behind the visual nature of Sparkle, if you want a coding environment I think it’s always been crystal clear Sparkle is not it.

Get in touch via email if this is unsatisfactory and you want a refund. We don’t want unhappy customers!

Output with an empty text box. Looks like jQuery to me. But I’m not a coder, I make my money with a quite succsessful visual design agency.

I think you are taking this the wrong way. Yes we use jquery today. I just said “don’t rely on it always being there”.

Aha, the customer is taking it the wrong way, when he wants something cleared, that could help him to do his job better with a tool he pays for.

Sorry, but I took it exactly as it was communicated. I help myself – thank you.

That’s not the point. The point is you can’t take a product in a direction you wish, just because you paid. Sparkle’s direction is very clearly not code-based.

If that wasn’t clear when you purchased Sparkle, my apologies. As mentioned above, an email will fix it.

1 Like

The point is, that I’m not criticizing Sparkle and I don’t want to take it “in a direction I wish, just because I paid”. And I don’t need and want a refund. I like Sparkle.

What I don’t like is the style you communicate to me in this case – reflect on this, please. All I asked for was: If(!) there is a way to trigger jQuery by Sparkle’s embed feature, please tell me how to do that. If the answer is “no there isn’t a way to do that”, then that’s the way it is. No need to defend “your baby”.

We have not added any way to do that directly.

I would just like to add, that I am fully behind a non coding approach and using Sparkle as a visual web design application. I have the greatest respect for the developers and what they have been able to achieve so far with Sparkle’s design ethos. Before Sparkle I used another piece of software to build websites, and my God what a hideous and awful experience it was to build a website etc. Thank You Duncan and Co for designing such a friendly and easy to use visual editor that for the average person is a joy to use.