Skip to content

Commit

Permalink
c-append/c-prepend added to cruRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
Iazzetta committed Feb 18, 2024
1 parent 4cf5321 commit de601f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/cru-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/cru-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/cru.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const cruRequest = async (el, method) => {
const removeClosest = el.getAttribute('c-remove-closest') || false
const redirect = el.getAttribute('c-redirect') || false
const swap = el.getAttribute('c-swap') || false;
const append = form.getAttribute('c-append') || false;
const prepend = form.getAttribute('c-prepend') || false;
const callback = el.getAttribute('c-callback') || false
const target = el.getAttribute('c-target') || false;
// request
Expand All @@ -80,6 +82,8 @@ const cruRequest = async (el, method) => {
// callbacks
if (removeClosest) el.closest(removeClosest).remove()
if (swap) $cru(swap).outerHTML = content
if (append) $cru(append).insertAdjacentHTML('beforeend', content)
if (prepend) $cru(prepend).insertAdjacentHTML('afterbegin', content)
if (reloadContainer) $cruLoadContainer(el)

if ($target) {
Expand Down

0 comments on commit de601f4

Please sign in to comment.