Button -- onClick

How do you get buttons to do anything in Bootstrap Studio without converting to HTML and editing the HTML yourself? I tried adding "onClick" as a key and <script>myfunction()</script> as the value in the "Attributes" section -- and I also tried it without the script tags ("myfunction()"). It did not work. I saw comments on this forum that suggest that any key beginning with the word "on" have been disabled -- is that true? Is there an advanced setting that would allow me to use onClick? Is there some other trick? Although I know how to do everything from scratch, I'd prefer not to because then I can't use the other nice features of BSS.

'on' events are disabled in BSS because the author thinks those could be a security risk. Or something like that. Search the forums, it's been discussed in the past.

I don't understand the security risk.... Is there a work-around for getting buttons to do things without using an "on" event

I've run into this problem as well. I think the only solution is to hand code the button yourself.

Keeping in mind that if coded correctly they will work when exported so once you have a working setup you won't need to keep testing the functionality.

I don't understand the security issues mindset either. We should be able to do what we need to Do as a designer/developer. When we are blocked from doing so it takes away the ability to make this the main go to app.

@martin: Can you tell us what exactly the security issues are in an app like this when they include certain functionality? I'm curious as it is the same for many apps that deal with proprietary file systems.

Sorry for jumping in this thread so late!

The recommended way to add event listeners to buttons and other elements is to write JavaScript/jQuery code like this: $("#button-id").click(function(){ /* your action here */})

As for the security aspect, we disabled on* attributes in earlier releases to prevent JS code from running in Bootstrap Studio. But I think we can make this better. We can just ignore these attributes in the app itself, and add them only when previewing/exporting. We'll look into it.

1 Like

Thank you!