I am trying to disable a text entry setting if the preceeding setting does not require its value.
.setDisabled() does not seem to be working
Also I cannot seem to access the whole settings control div element. That in the main settings “Files and links” > “Default location for new attachments”, “Attachment folder path” has its div add a `style:=“display: none;”.
const texImageDirectorySetting = new Setting(containerEl) .setName('TeX Image Directory') .setDesc('Where to save rendered TeX images') .addDropdown(dropdown => dropdown .addOption('vault', 'Vault Root') .addOption('vault-subdirectory', 'Vault Sub directory') .addOption('obsidian', 'Obsidian Directory') .addOption('current', 'Current Markdown directory') .addOption('subdirectory', 'Markdown Sub directory') .setValue(this.plugin.settings.texImageDirectory || 'vault') .onChange(async (value) => { this.plugin.settings.texImageDirectory = value; await this.plugin.saveSettings(); (<HTMLElement>subdirectorySetting.controlEl.parentNode).setAttribute("style", value == 'subdirectory' || value == 'vault-subdirectory' ? "" : "display: none;"); //subdirectorySetting.setDisabled(this.plugin.settings.texImageDirectory == 'vault' || this.plugin.settings.texImageDirectory == 'obsidian') })); const subdirectorySetting = new Setting(containerEl) .setName('Subdirectory') .setDesc('Subdirectory relative to the Markdown file for storing images') .addText(text => text .setPlaceholder('Enter subdirectory name') .setValue(this.plugin.settings.markdownAttachmentSubdirectory) //.setDisabled(this.plugin.settings.texImageDirectory == 'vault' || this.plugin.settings.texImageDirectory == 'obsidian') .setDisabled(true) .onChange(async (value) => { this.plugin.settings.markdownAttachmentSubdirectory = value; await this.plugin.saveSettings(); }));
I cannot seem to get the div element for the whole control setting’s div. The following is how I seem to be able to make is disappear :-
(subdirectorySetting.controlEl.parentNode).setAttribute(“style”, value == ‘subdirectory’ || value == ‘vault-subdirectory’ ? “” : “display: none;”);
neither :-
- descEL
- infoEl
- controlEl
seem to access the setting’s div element.
Can someone put me straight on these issues or point me to an example plugin that shows how to do this please ?