RESULTING, the question is this: 1. $ (myframeid) .attr (src ...) AND 2. $ ('div.selectors-container'). append (nextOneSelectorHtml); /// you need to "draw" 1 or 2, depending on whether you selected the selection or not.
function rendSelects($currentSelectItem, strPath) { //1of3 // let add a boolean var is_highlighted_here = false; var highlighted_path=""; //done. var currentSelectLevel = (null === $currentSelectItem ? -1 : parseInt($currentSelectItem.attr('data-selector-level'))), nextOneSelectorHtml = '<select ' + 'class="dropdown selectpicker" ' + 'name="dd" ' + 'data-selector-level="' + (currentSelectLevel + 1) + '" ' + 'data-path="' + strPath + '" ' + 'onchange="onFsSelectChange(this)"' + '><option text selected> -- select an option -- </option>'; $('div.selectors-container select.dropdown').each(function (i, el) { if (parseInt(el.getAttribute('data-selector-level')) > currentSelectLevel) { el.parentNode.removeChild(el); $(el).selectpicker('destroy'); } }); if (fsStructure[strPath].subfolders.length > 0) { for (var i = 0; i < fsStructure[strPath].subfolders.length; i++) { nextOneSelectorHtml += '<option ' + 'class="subfolder-option" ' + 'data-subfolder="' + fsStructure[strPath].subfolders[i] + '" >' + fsStructure[strPath].subfolders[i] + '</option>'; } } if (fsStructure[strPath].subshtmls.length > 0) { for (var i = 0; i < fsStructure[strPath].subshtmls.length; i++) { // 2of3 // oh !! look at here : if( fsStructure[strPath].subshtmls[i].indexOf("highlighted")>=0 ) { s_highlighted_here=true; highlighted_path = fsStructure[strPath].subshtmls[i]; } //done. scroll to bottom. nextOneSelectorHtml += '<option ' + 'class="html-page-option" ' + 'data-html-page-name="' + fsStructure[strPath].subshtmls[i] + '">' + fsStructure[strPath].subshtmls[i] + '</option>'; } } nextOneSelectorHtml += '</select>'; // 3of3 // here finally if(is_highlighted_here) { $("#myiFrame").attr('src', highlighted_path); } else { $('div.selectors-container').append(nextOneSelectorHtml); $('div.selectors-container').trigger('dropdownadded.mh'); } }//function end
Well, if I just changed the display: - when starting the function itself:
//1of3 var is_highlighted_here = false; var highlighted_path="";
when parsing the struct folder:
// 2of3 // oh !! look at here : if( fsStructure[strPath].subshtmls[i].indexOf("highlighted")>=0 ) { s_highlighted_here=true; highlighted_path = fsStructure[strPath].subshtmls[i]; }
And finally, when rendering:
// 3of3 if(is_highlighted_here) { $("#myiFrame").attr('src', highlighted_path); } else { $('div.selectors-container').append(nextOneSelectorHtml); $('div.selectors-container').trigger('dropdownadded.mh'); }
source share