Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listener nested Matrix preserving data across query data refresh #2525

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion public/js/manifest.js

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

8 changes: 4 additions & 4 deletions public/js/orchid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/vendor.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion resources/js/controllers/listener_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export default class extends ApplicationController {

targets.forEach(name => document.querySelectorAll(`[name="${name}"]`)
.forEach((field) => {
let fieldIndex = targets.findIndex(i => i === field.name);

if (fieldIndex > -1) {
targets.splice(fieldIndex, 1);
}

if ((field.type === 'checkbox' || field.type === 'radio') && !field.checked) {
return;
Expand All @@ -43,7 +48,10 @@ export default class extends ApplicationController {
} else {
params.append(name, field.value);
}
}));
})
);

targets.forEach(name => document.querySelectorAll(`[id^="matrix-field-${name}"]`).forEach(e => params.append(e.name, e.value)));

this.asyncLoadData(params).then(() => {
document.dispatchEvent(
Expand Down