Custom Script working only on reload

Hi,

I have some function which i have included in the path sites/assets/js/common.js and added in hooks.

The file content is getting fetched when i give reload option from the menu in right top.

example

i have added a button called back in the common.js page

frappe.ui.form.on(doctype_name, “refresh”, function(frm) {
frm.add_custom_button(__(“Back”), function() {

	frappe.confirm(
		    'Are you sure to leave this page?',
		    function(){
		       
		        var route = frappe.get_route();
	    	 frappe.set_route("List", route[1]);
	    	 return false;
		    },
		    function(){
		    	 window.close();
		    	
		    }
		)
});

});

its working when i reload the doc each time.

How to resolve ths without reload.

try changing refresh with onload

Ya @ahmad18189.

i have tried that too. But i’m facing the same issue.