Need to remove Close(X) button from spmodal

Prem13
Tera Contributor

I created a onload catalog client script with the following script(note: not in the widget)

function onLoad() {
  spModal.open({
			title: 'Test.',
			message: "ACknowledge before proceeding",
		
			size: "md",
			buttons: [
				{label:'I Acknowledge', primary: true},
				//{label:'Cancel', primary: false}
			]
		}).then(function(ans){
			if (ans.label == "I Acknowledge"){
				//alert('party');
				
			} 
		});
	
   
}

This is how the popup comes up during catalog item form load.

find_real_file.png

 Need to remove close button(x) which is at right corner.

Note: this is not on widget , the script which i wrote is  onload  catalog client script

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Hi Prem,

I have written this and works:

function onLoad() {

	spModal.open({
		title: 'Test.',
		message: "Acknowledge before proceeding",
		backdrop: 'static',
		size: "md",
		buttons: [
			{label:'I Acknowledge', primary: true},
		]
	}).then(function(ans){
		if (ans.label == "I Acknowledge"){
			//alert('party');

		} 
	});
	var checkExist = setInterval(function() {
		if (top.document.getElementsByClassName('close pull-right')[0]) {
			clearInterval(checkExist);
			var x = top.document.getElementsByClassName('close pull-right')[0];
			x.style.display = "none";
		}
	}, 100); // check every 100ms

}

View solution in original post

11 REPLIES 11

Jim Coyne
Kilo Patron

I know the question is old, but as @xiaix mentioned, you should probably use the "noDismiss" option as DOM manipulation is just not the best way to do things, especially if you have an OOTB way to do it.  And in addition, the "backdrop" and "keyboard" options are useful:

 

function onLoad() {
    spModal.open({
        noDismiss: true,    //removes the title and "x" button in the top-right corner
        backdrop: "static", //makes it a true modal, will not close the window if clicked outside the window
        keyboard: false,    //will not allow the "Esc" key to close the window
        size: "sm",         //"md" is not actually a choice, only "sm" or "lg"
        title: "Test",      //would be removed by the "noDismiss" option
        message: "Acknowledge before proceeding",
        buttons: [{
			label: "I Acknowledge",
			primary: true
		}]
    }).then(function() {
        spModal.alert("party");  //when "I Acknowledge" is clicked
    });
}

 

Unfortunately these options are NOT documented in the Docs article on spModal.

Dinesh61
Tera Contributor

Hi Everyone,

Can we override the "close modal" to close

 

Dinesh61_0-1736409583133.png