Skip Navigation

[Geschlossen] Using JS to show hide search field options when label is clicked.

This support ticket is created vor 3 Wochen, 4 Tage. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Dieses Thema enthält 3 Antworten, hat 1 Stimme.

Zuletzt aktualisiert von Christopher Amirian vor 3 Wochen, 1 Tag.

Assistiert von: Christopher Amirian.

Author
Artikel
#2782794

I have a view on: versteckter Link

I'm using JS to show/hide the field options when a user clicks on the label for the field.

function toggle_visibility(id, symbolId) {
var e = document.getElementById(id);
var symbol = document.getElementById(symbolId);

if (e.style.display === 'block') {
e.style.display = 'none';
symbol.innerText = '+';
} else {
e.style.display = 'block';
symbol.innerText = '-';
}
}

The issue only happens if I have "Show only available options for each input" checked in the view edit options.

I've tried adding an event listener to stopPropagation, and storing the options in sessionStorage, but none of it is working.

So the updating of the choices is the cause.

Any help is appreciated. Thank You.

#2782944

Christopher Amirian
Supporter

Sprachen: Englisch (English )

Hi,

I did not understand what is the issue in the first place. I checked the website, it seems to be working ok.

Please give me detailed steps I should take to see the problem to understand.

Thanks.

#2783012

My apologies. A couple of sentences seem to be missing from my initial question.

The JS code opens the field options when the label is clicked. That works. But since I have "Show only available options for each input" once the user makes a selection the options close, when they should remain open.

To recreate.

Go to: versteckter Link
Click on "Room Types +" then make a selection like "Private Room".
After you've selected Private Room the field options close, when they should remain open until the field label "Room Types -" is clicked again.

Thank You and let me know if you need more info.

#2783074

Christopher Amirian
Supporter

Sprachen: Englisch (English )

Hi,

Now I understand. It is not possible to change that as you use the Ajax loading functionality. The Ajax code replaces the whole HTML code with a new set of data, that is why your code will not work when the new set of data will be replaced.

It will be a long Custom Javascript code, to store the current state of the labels (which one is expanded and which one is collapsed) and attach the code to AjaxComplete jQuery event which triggers when the Ajax loading is finished.

Then it needs to traverse all the labels and set the correct state to the label.

This is way outside of our support scope and you are welcome to hire a developer to do that for you:

https://toolset.com/contractors/

Thanks.

Das Thema „[Geschlossen] Using JS to show hide search field options when label is clicked.“ ist für neue Antworten geschlossen.