mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
LinkHints: trigger onclick event for checkboxes (#4870)
* LinkHints: trigger onclick event for checkboxes * refactor Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
a52ab7329b
commit
553d1f2319
|
@ -1482,7 +1482,7 @@ LinkHints.prototype.hintActivate = function (hint) {
|
|||
this.activatedDropdown.classList.toggle("force-nav-hover");
|
||||
hint.parent.focus();
|
||||
} else if (hint.parent.type === "checkbox") {
|
||||
hint.parent.checked = !hint.parent.checked;
|
||||
this.toggleCheckbox(hint);
|
||||
} else if (hint.parent.type === "submit") {
|
||||
hint.parent.click();
|
||||
} else if (hint.parent.nodeName === "INPUT" || hint.parent.nodeName === "TEXTAREA") {
|
||||
|
@ -1493,6 +1493,19 @@ LinkHints.prototype.hintActivate = function (hint) {
|
|||
}
|
||||
};
|
||||
|
||||
LinkHints.prototype.toggleCheckbox = function (hint) {
|
||||
// ensures that onclick handler is executed
|
||||
// https://stackoverflow.com/questions/41981509/trigger-an-event-when-a-checkbox-is-changed-programmatically-via-javascript
|
||||
var event = document.createEvent("HTMLEvents");
|
||||
var checked = hint.parent.checked;
|
||||
event.initEvent("click", false, true);
|
||||
hint.parent.parentElement.dispatchEvent(event);
|
||||
if (checked === hint.parent.checked) {
|
||||
// fallback if no handler is registered
|
||||
hint.parent.checked = !hint.parent.checked;
|
||||
}
|
||||
};
|
||||
|
||||
LinkHints.prototype.filterHints = function () {
|
||||
var visibleHints = 0;
|
||||
for (var i = this.hintsMap.first; i <= this.hintsMap.last; i++) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user