I have this code in the index.html of my blazor webassembly project:
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss"></a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script>navigator.serviceWorker.register('service-worker.js');</script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/interop.js"></script>
and this is the interop.js file that is in the js folder of wwwroot. But I get error:
Unhandled exception rendering component: Could not find 'interop.disableDivInputs' ('disableDivInputs' was undefined)
I use this code:
await jsRuntime.InvokeVoidAsync("interop.disableDivInputs", "person");
and the interop.js is:
window.blazorCulture = {
get: () => window.localStorage['BlazorCulture'],
set: (value) => window.localStorage['BlazorCulture'] = value
};
window.interop = {
setProperty: function (name, value) {
localStorage.setItem(String(name).toLowerCase(), value);
return value;
},
getProperty: function (name) {
return (localStorage.getItem(String(name).toLowerCase()) || "");
},
setjson: function (key, value, location) {
if (location === "LocalStorage") {
localStorage.removeItem(String(key).toLowerCase());
localStorage.setItem(String(key).toLowerCase(), value);
}
else {
sessionStorage.removeItem(String(key).toLowerCase());
sessionStorage.setItem(String(key).toLowerCase(), value);
}
return true;
},
getjson: function (key, location) {
if (location === "LocalStorage") {
return (localStorage.getItem(String(key).toLowerCase()) || "");
}
else {
return (sessionStorage.getItem(String(key).toLowerCase()) || "");
}
},
setObject: function (name, value) {
try {
localStorage.setItem(name, JSON.stringify(value));
return true;
}
catch (e) {
return false;
}
},
disableDivInputs: function (divId) {
$(`#${divId} :input`).prop('readonly', true);
$(`#${divId} :select`).prop('readonly', true);
}
};
How to make this work?