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

vkachineni
Kilo Sage
Kilo Sage

Update the catalog client script

find_real_file.png

function onLoad() {
    //alert(this.document);
    //alert(document);    
    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');

        }
    });

    setTimeout(function() {
        var closeButton = this.document.getElementsByClassName('close pull-right');
        //console.log(closeButton.length);
        for (var i = 0; i < closeButton.length; i++) {

            closeButton[i].style.display = 'none';
        }

    }, 0);

}
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

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

}

@Prem Does it work for you? Please mark as Correct answer to help others find it as well😄

Willem
Giga Sage
Giga Sage

@Prem is this issue resolved? If so, kindly mark answer as Helpful and Correct to close the thread.

xiaix
Tera Guru

Use the noDismiss option:

 

function onLoad() {
  spModal.open({
			title: 'Test.',
			message: "ACknowledge before proceeding",
			noDismiss: true, /* if true, then options.headerStyle will be: display: 'none' */
			size: "md",
			buttons: [
				{label:'I Acknowledge', primary: true}
			]
		}).then(function(ans){
			if (ans.label == "I Acknowledge"){
				//alert('party');
				
			} 
		});
}