• Resolved MisterChaos

    (@mattp225)


    Hi Tom,

    I’m loving this plugin.

    Quick question and possible feature request. With the buttons block, it would be really handy for me to be able to add certain Javascript triggers, for example, an onclick attribute to trigger modal popups and assorted things.

    1. Is this available already and I’m not seeing how to do it? If so, what are the steps?

    2. If it’s not already a feature, could we get this added in?

    Cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tom

    (@edge22)

    Hi there,

    We have a custom attributes feature coming in the pro version, but it doesn’t include onclick at the moment for security purposes. I played with it a bit, and it’s a nightmare in the editor as well (you need to click the block to edit it).

    It will allow you to add data-* attributes that you can use with to target elements with javascript. Of course, you can use custom classes to do this right now in the free version.

    Let me know if you need more info ??

    Thread Starter MisterChaos

    (@mattp225)

    Got it, thanks.

    I was using the button to trigger an email collection popup, which uses onclick… I thought it could be something as simple as adding an attribute to the block settings, sort of like it’s done with the CSS classes.

    This helps, though. I’ll check the alternatives you suggested. Thanks again.

    Plugin Author Tom

    (@edge22)

    No problem!

    Inline javascript can be a pain, better to do this:

    document.querySelector( '.my-button-class' ).addEventListener( 'click', function( e ) {
        // Do onclick stuff in here.
    } );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding Javascript attributes to buttons’ is closed to new replies.