Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Make a BB Column Clickable
/**
* Makes a BB Column clickable.
* Pre-requisite: There must be an A Tag contained within the column element.
*/
(function($){
// Exit if BB layout is in edit mode.
if ( 'undefined' != typeof window.FLBuilderConfig ) {
return;
}
$('.clickable-col').css('cursor', 'pointer');
$('.clickable-col').on('click', function(event){
$(this).find('a')[0].click();
});
$('.clickable-col a').on('click', function(event){
event.stopPropagation();
});
})(jQuery);
@carlosonweb
Copy link
Author

Good catch @zackpyle. Thanks for your input. We can also check for window.FLBuilderConfig to see if the layout is in edit mode or on the live page like so:

    if ( 'undefined' != typeof window.FLBuilderConfig ) {
        // Layout is not in BB Edit mode.
    }

I'm updating the code to this:

(function($){

    if ( 'undefined' != typeof window.FLBuilderConfig ) {
        return;
    }
    
    $('.clickable-col').css('cursor', 'pointer');
    $('.clickable-col').on('click', function(event){
        $(this).find('a')[0].click();
    });

    $('.clickable-col a').on('click', function(event){
        event.stopPropagation();
    });
})(jQuery);

@zackpyle
Copy link

👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment