Skip to content
Open
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
26 changes: 17 additions & 9 deletions src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4177,7 +4177,7 @@ var htmx = (function() {
* @param {Element} elt
* @param {Event} event
* @param {HtmxAjaxEtc} [etc]
* @param {boolean} [confirmed]
* @param {string|boolean} [confirmed]
* @return {Promise<void>}
*/
function issueAjaxRequest(verb, path, elt, event, etc, confirmed) {
Expand Down Expand Up @@ -4232,7 +4232,11 @@ var htmx = (function() {
// allow event-based confirmation w/ a callback
if (confirmed === undefined) {
const issueRequest = function(skipConfirmation) {
return issueAjaxRequest(verb, path, elt, event, etc, !!skipConfirmation)
// convert non-empty strings to boolean
const skip = (typeof skipConfirmation === 'string' && skipConfirmation.length > 0)
? skipConfirmation
: !!skipConfirmation;
return issueAjaxRequest(verb, path, elt, event, etc, skip)
}
const confirmDetails = { target, elt, path, verb, triggeringEvent: event, etc, issueRequest, question: confirmQuestion }
if (triggerEvent(elt, 'htmx:confirm', confirmDetails) === false) {
Expand Down Expand Up @@ -4325,13 +4329,17 @@ var htmx = (function() {
}
const promptQuestion = getClosestAttributeValue(elt, 'hx-prompt')
if (promptQuestion) {
var promptResponse = prompt(promptQuestion)
// prompt returns null if cancelled and empty string if accepted with no entry
if (promptResponse === null ||
!triggerEvent(elt, 'htmx:prompt', { prompt: promptResponse, target })) {
maybeCall(resolve)
endRequestLock()
return promise
if (confirmed) {
var promptResponse = confirmed
} else {
var promptResponse = prompt(promptQuestion)
// prompt returns null if cancelled and empty string if accepted with no entry
if (promptResponse === null ||
!triggerEvent(elt, 'htmx:prompt', { prompt: promptResponse, target })) {
maybeCall(resolve)
endRequestLock()
return promise
}
}
}

Expand Down