Hook to wallets_ready event in frontend JavaScript code

in bitcoin •  6 years ago 

In the latest version 3.5.1 of Bitcoin and Altcoin Wallets you can now write JavaScript code that executes on some wallets-related event.

For example, you could choose to set the default coin, once the coin information is loaded from the JSON API. Do this like so:

jQuery( 'body' ).on( 'wallets_ready', function( event, coins, nonces ) {
    if ( 'object' === typeof coins.BTC ) {
        wp.wallets.viewModels.wallets.selectedCoin('BTC');
    }
} );
There are full instructions on this in the documentation, under the Section FrontendFrontend UI JavaScript event bindings. The documentation lists all of the available events, and sample code on how to enqueue your JavaScript file using wp_enqueue_script().
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!