image CryptoWiz Manual and
Documentation

Post-init hook

This snippet will define a function that will run after the buttons have been rendered:

<script type="text/javascript">

   

    //////////////////////////////////////////////////////////

    // Hook sample for CryptoWiz Controller post-init event //

    //////////////////////////////////////////////////////////

   

   

    // First, we check if the callbacks array is undefined.

    // If so, we’ll init it.

    if ( typeof wpuni_mciwidget_postinit_callbacks === 'undefined' )

        wpuni_mciwidget_postinit_callbacks = [];

   

    // At this moment, all button links have been converted to buttons.

    // Here’s our hook:

    wpuni_mciwidget_postinit_callbacks[wpuni_mciwidget_postinit_callbacks.length] = function() {

        console.log('Running my custom CryptoWiz post-init now!');

       

        // Let’s load all button links in an array

        var $all_buttons = jQuery('.' + wpuni_mcwidget._default_selector_classname + '[converted_link]');

       

        // Now let’s do something with them!

        $all_buttons.each(function() {

            var $button = $(this);

            console.log(

                'Here is a button ~ id:%s caption: %s',

                $button.attr('button_id'),

                $button.attr('caption')

            );

        });

    };

 

</script>

Remember: the hooks must be added before the invocation script, and preferably, this should be added at the end of the <body> while the hook snippets should be added somewhere on the <head>.

© 2018 Blockchain Financial image