I reply to all queries on the forums and via email, once per day, Monday to Friday (not weekends).

If you are new here, please see some information on how to ask for support. Thank you!

Reply To: Adding a knockout.js data binding on the balance template

dashed-slug.net Forums General discussion Adding a knockout.js data binding on the balance template Reply To: Adding a knockout.js data binding on the balance template

#11453
alexg
Keymaster

Hello,

This would be so much easier if you were working on wallets6, but unfortunately it’s not ready for release just yet.

Oh well, I guess you could do this:

<a class="button" data-bind="attr: { href: '?symbol=' + selectedCoin() + '&balance=' + currentCoinBalance() }">Button!</a>

The mistake I did in the past is that in wallets 5.x the UI JavaScript is a big bunch of spaghetti code (wallets-ko.js). I have since changed the templates to make everything clear and self-contained and extendable. You’ll see 🙂

In any case, make sure you make your changes in a theme or child theme. The documentation explains how in: Frontend -> Template Modifications -> Modifying markup. TL;DR, you should copy balances.php to wp-content/themes/YOURTHEMEORCHILDTHEME/templates/wallets/balances.php and do your changes there…

And if you do need to run any javascript on the UIs, you should run it after the data loads, on the wallets_ready bubbling event. So, to hook to that event, you would do:

	jQuery( 'body' ).on( 'wallets_coins_ready', function( event, coins ) {
		// TODO do your thing here!
	} );

Hope this helps.