Close window after save button clicked

Hi guys,
I am pretty new here and this is my first post. Please accept my appolgy if this post is worng place.

I have been assigned new project in our company, previous guy left me a total rubbish. He used dHTMLX and put more than 18000 lines of code in a single JS file.

Anyway, now i am trying to find out some solution as i describe in this post’s subject. So, i have to close opened window after save and refresh previous screen.

Here is my code.

[code]CF.attachEvent("onValidateError", function (name, value, result){
		if(!result)
        {    
            Label = CF.getItemLabel(name);
            CurrentErrorMessages.push('"'+Label+'" cannot be empty.');
        }
        a.progressOff();
        b.progressOff();
        return false;
    });
    
    CF.attachEvent("onButtonClick",function(id){
        if(id=="currentform-send")
        { 
            
       		CurrentErrorMessages = [];
            var vld = CF.validate();
            if(!vld && CurrentErrorMessages.length>0){ 
                
                dhtmlx.message({ title:"Error",text:CurrentErrorMessages.join("<br>") }); 
				return false;
            }

            var NotCSVString = CFN.serializeToCSV();	

            CF.setItemValue("Notes",NotCSVString);						

            a.progressOn(); 
            b.progressOn();

            CF.send("/api/current/save", function(loader, response){ 

                a.progressOff();
                setTimeout(function(){ b.progressOff(); },200);

                json_res = JSON.parse(response);  
                if(json_res['status']=='ERROR'){
                    dhtmlx.alert({ title:"Error",type:"alert-error",text:json_res['error_message'] });
                }
                else if(json_res['status']=='OK')
                {
                    dhtmlx.message({text: "Success" });
                }
            });
        }
    });[/code]

I appreciate for any help

You’re welcome :slight_smile:

I can suggest that CF is a form, and a and b are cells. Not sure if CF is attached to a or b but probably yes and probably it your window. If so you have to add a.close(); or b.close(); some where here: else if(json_res[‘status’]==‘OK’) { seems like here response from server is ok }, if not - you have to find out CF parent, look through the code above and find statement like var someVar = …createWindow(…); then you have to call someVar.close();

if above tips will not help, please send link and steps to reproduce to support at dhtmlx dot com.

also try to find sources

Thanks Andrei.

Problem solved.