Skip to content
Advertisement

JSInvokable Blazor method not being called

I’m trying to invoke a Blazor method in JavaScript inside of an OnSuccess callback for the Plaid API.

Here’s the JavaScript that’s being run:

JavaScript

Here’s the Blazor code being used:

JavaScript

The Blazor method InitializePlaid is being called to invoke the JS method InitializePlaidLink. Then, on success, the Blazor method OnPlaidLink Success should be called.

I used log statements to confirm that there is a public_token and the JS after the objRef.invokeMethodAsync() is being reached. Also I was able to invoke a Blazor method in a similar way with a different JS method, just not a method with the Plaid API and the onSuccess callback.

Advertisement

Answer

OnPlaidLinkSuccess was being called correctly. The property this.PublicToken was being correctly updated, but the DOM was not being updated for the user to see. Calling this.StateHasChanged() fixed this.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement