The CreatorCon Call for Content is officially open! Get started here.

Taking long time to load

kelango87
Kilo Explorer

Hi,
i used below script( code) to hide the variable in request item, but the request item form is getting long time to load because this script use (DOM Approach). it will check each and every variable in the form. So, how to optimise this code to reduce the loading time.

function onLoad(){
try{
//Get the 'Variables' section
var ve = $('variable_map').up('table');
//Disable all elements within with a class of 'cat_item_option'
ve.select('.cat_item_option', '.slushselectmtm', '.questionsetreference').each(function(elmt){
//Special handling to allow scroll/copy in textarea and fix lost date on save issue
if((elmt.tagName.toLowerCase() == 'textarea') || (elmt.tagName.toLowerCase() == 'input' && elmt.type.toLowerCase() == 'text')){
elmt.readOnly = true;
}
//Everything else gets disabled
else{
elmt.disabled = true;
}
});
//Remove any reference or calendar icons
ve.select('img[src*=reference_list.gifx]', 'img[src*=small_calendar.gifx]').each(function(img){
img.hide();
});
//Hide list collector icons
ve.select('img[src*=arrow]').each(function(img){
img.up('table').hide();
});
}
catch(e){}
}

3 REPLIES 3

adiddigi
Tera Guru

If your goal is to hide the variables on a variable editor, there is a better approach to this : you need to use,


g_form.setDisplay('variables.<varible_name>', false)


And if you are using DOM, it will take time because of the reason that it needs to get each and every element.


thanks for your guide but i need to write the script which is applicable to all the request item.


If I understand it correctly, You want to hide all variables on the Variable editor? Then yes, You need to write the line of code that I gave you to hide each and every variable.

Correct me if I am wrong, By showing me what you would want to do.