Closed mosBrkr closed 3 months ago
Ok I think I got it resolved! I had to add the following scripts (as also in your example) to my App.razor file:
<script>
var path = window.location.pathname.split('/');
var base = document.getElementsByTagName('base')[0];
if (window.location.host.includes('localhost')) {
base.setAttribute('href', '/');
} else if (path.length > 2) {
base.setAttribute('href', '/' + path[1] + '/');
} else if (path[path.length - 1].length != 0) {
window.location.replace(window.location.origin + window.location.pathname + '/' + window.location.search);
}
</script>
<script>
function jSReference(element) { return element.valueOf(); }
function newJSReference() { return {}; }
function getAttribute(object, attribute) { return object[attribute]; }
function setAttribute(object, attribute, value) { object[attribute] = value; }
function toBlob(canvas, blobCallback) {
var blobWrapper = {};
canvas.toBlob(
(blob) => {
blobWrapper.blob = blob;
blobCallback.objRef.invokeMethodAsync('Callback');
},
quality = 1);
return blobWrapper;
}
</script>
Now it works!
Hi there
First of all thanks for the great work!
Actually I try to do something very similar as your 'IndexedDB' example but I'm running into a problem using the latest .NET 8 'Blazor Web App' template.
Steps to reproduce: Create a new 'Blazor Web App' project
Add the following package dependencies:
Configure IndexedDB:
Add the service in Program.cs (copy/paste from example):
Configure FileSystemAccess:
Replace the whole 'Counter' component by the 'IndexedDB' component (copy/paste from example) and add the necessary usings.
Run and navigate to the 'Counter' page results in the error:
As far as I could track it down the JS function 'getAttribute' is not recognized even though the files 'KristofferStrube.Blazor.FileSystemAccess.js', 'KristofferStrube.Blazor.FileSystem.js' and 'KristofferStrube.Blazor.FileAPI.js', are correctly loaded (which all contain a definition for that function).
Do you have an idea why the function isn't recognized?
Edit: Here is a repo containing the mentioned changes: https://github.com/mosBrkr/IndexedDbIssue/