This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelector('.my-form') | |
.addEventListener('change', (e) => { | |
if (e.target.closest('.radio-input') !== null) { | |
console.log(`${e.target.value} is picked`); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const radioInputs = document.querySelectorAll('.radio-input') | |
for(let input of radioInputs) { | |
input.addEventListener('change', e => { | |
console.log(`${e.target.value} is picked`) | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const radioInputs = document.querySelectorAll('.radio-input') | |
for(let input of radioInputs) { | |
input.addEventListener('change', e => { | |
console.log(`${e.target.value} is picked`) | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.radio-input').change((e) => { | |
console.log(`${e.target.value} is picked`) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form class="my-form"> | |
<fieldset class="input-field" role="radiogroup" tabindex=0> | |
<legend class="form-label">Venue Location</legend> | |
<div class="radio-button-container"> | |
<div class="radio-button-group" tabindex=0> | |
<input type="radio" class="radio-input" id="sydney" | |
name="venue" value="Sydney" /> | |
<label class="radio-label" for="sydney"> | |
<span class="ph-tick"></span> | |
Sydney |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const initialiseDbAndFetchData = async () => { | |
const initialDataArray = [ | |
initialList, | |
initialCategories | |
] | |
const keyArray = ['list', 'category'] | |
if (checkIndexDbBrowserSupport) { | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const clearIndexedDB = (): Promise<string> => { | |
const req = indexedDB.deleteDatabase('mtd') | |
return new Promise((resolve, reject) => { | |
req.onsuccess = () => { | |
resolve('DB deleted successfully') | |
} | |
req.onerror = (e: any) => { | |
reject(`Error in DB delete: ${e.target.error}`) | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const insertRecordToIndexedDb = (data: any, key: string) => { | |
let db | |
const request = indexedDB.open('mtd', 1) | |
return new Promise((resolve, reject) => { | |
request.onsuccess = (e: any) => { | |
db = e.target.result | |
console.log('opened indexedDb to upsert...', db) | |
if (db.objectStoreNames.contains('mtd-data')) { | |
const transaction = db.transaction('mtd-data', 'readwrite') | |
const store = transaction.objectStore('mtd-data') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getReadOnlyStore = () => { | |
// db is defined at the top | |
const request = indexedDB.open('mtd', 1) | |
return new Promise((resolve, reject) => { | |
request.onsuccess = (e: any) => { | |
db = e.target.result | |
const transaction = db.transaction('mtd-data', 'readonly') | |
const store = transaction.objectStore('mtd-data') | |
resolve(store) | |
} |