Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions assets/js/odyssey.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
const Hooks = {
OdysseyActivityPicker: {
// Function to add global event listeners
function addOdysseyGlobalEvents(windowObj) {
// Global event listener for triggering input events on form fields, this is
// needed for input fields that maintain a hidden input field behind the scenes
// and need to tell the parent form when a change has been made.
windowObj.addEventListener("phx:trigger-input", (event) => {
const { field_id } = event.detail
const input = windowObj.document.getElementById(field_id)
if (input) {
input.dispatchEvent(new Event('input', { bubbles: true }))
}
})
}

const OdysseyHooks = {
OdysseyActivityPicker: {
mounted () {
const picker = this.el.querySelector('odyssey-product-picker')

Expand All @@ -24,4 +38,5 @@ const Hooks = {
}
}

export default Hooks
export { OdysseyHooks, addOdysseyGlobalEvents }
export default OdysseyHooks
3 changes: 2 additions & 1 deletion coveralls.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"test/*",
"lib/peek_app_sdk/application.ex",
"lib/peek_app_sdk/ui/core_components.ex",
"lib/peek_app_sdk/ui/get_text.ex"
"lib/peek_app_sdk/ui/get_text.ex",
"demo/**"
],
"print_summary": true
}
Loading
Loading