fix: login form handlers not executing on innerHTML injection
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Login View
|
||||
|
||||
export function renderLogin({ onLogin }) {
|
||||
export function renderLogin() {
|
||||
return `
|
||||
<div class="login-screen">
|
||||
<div class="login-card">
|
||||
@@ -15,15 +15,20 @@ export function renderLogin({ onLogin }) {
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById('login-form').onsubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
const token = document.getElementById('token-input').value;
|
||||
const error = await onLogin(token);
|
||||
if (error) {
|
||||
document.getElementById('login-error').classList.add('visible');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
`;
|
||||
}
|
||||
|
||||
export function initLoginHandlers(onLogin) {
|
||||
const form = document.getElementById('login-form');
|
||||
const errorEl = document.getElementById('login-error');
|
||||
|
||||
form.onsubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
errorEl.classList.remove('visible');
|
||||
const token = document.getElementById('token-input').value;
|
||||
const error = await onLogin(token);
|
||||
if (error) {
|
||||
errorEl.classList.add('visible');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user