mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-29 05:51:39 +00:00
Add missing htmx:trigger event on load triggers
This commit is contained in:
parent
bc7ea4a8d9
commit
a5c5de9275
@ -2559,6 +2559,7 @@ var htmx = (function() {
|
|||||||
const load = function() {
|
const load = function() {
|
||||||
if (!nodeData.loaded) {
|
if (!nodeData.loaded) {
|
||||||
nodeData.loaded = true
|
nodeData.loaded = true
|
||||||
|
triggerEvent(elt, 'htmx:trigger')
|
||||||
handler(elt)
|
handler(elt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1043,6 +1043,28 @@ describe('hx-trigger attribute', function() {
|
|||||||
}, 50)
|
}, 50)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('fires the htmx:trigger event when the trigger is a load', function(done) {
|
||||||
|
this.server.respondWith(
|
||||||
|
'GET',
|
||||||
|
'/test',
|
||||||
|
'<div hx-trigger="load delay:50ms" hx-on::trigger="this.innerText = \'Done\'">Response</div>'
|
||||||
|
)
|
||||||
|
|
||||||
|
var div = make('<div hx-get="/test">Submit</div>')
|
||||||
|
div.click()
|
||||||
|
this.server.respond()
|
||||||
|
var response = div.children[0]
|
||||||
|
response.innerText.should.equal('Response')
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
try {
|
||||||
|
response.innerText.should.equal('Done')
|
||||||
|
done()
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
}, 100)
|
||||||
|
})
|
||||||
|
|
||||||
it('filters support "this" reference to the current element', function() {
|
it('filters support "this" reference to the current element', function() {
|
||||||
this.server.respondWith('GET', '/test', 'Called!')
|
this.server.respondWith('GET', '/test', 'Called!')
|
||||||
var form = make('<form hx-get="/test" hx-trigger="click[this.classList.contains(\'bar\')]">Not Called</form>')
|
var form = make('<form hx-get="/test" hx-trigger="click[this.classList.contains(\'bar\')]">Not Called</form>')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user