Service Portal click button calling function to pop-up dialog window

srevinU
Kilo Contributor

Hello,

I'm trying to handle the same thing but unfortunately my pop-up window is not called.

You will find my script below:

HTML Template:

  <div class="btn_save">
        <button type= "submit" class = "button" class="save_form" onClick="clickMethod()">Save</button>
      </div>

Client Script:

function clickMethod() {
	alert("Function called");
  if(confirm("Are you sure to delete ?")) {
    console.log("Implement save functionality here");
  }
}

I'm trying in this step to check if the call is working and run the function to display the 'alert' message. Any idea  why the function is not called ? 

FYI: When I use the 'alert('There is the alert') in the button html balise, the message is showing up, so I'm pretty sure that is coming from the 'client script' side and not form the html part.

Many thanks for your help !

1 ACCEPTED SOLUTION

VigneshMC
Mega Sage

Try this

HTML

  <div class="btn_save">
        <button type= "submit" class = "button" class="save_form" ng-click="clickMethod()">Save</button>
      </div>

Client script

function($scope) {
  /* widget controller */
  var c = this;
	
	$scope.clickMethod = function () {
	alert("Function called");
  if(confirm("Are you sure to delete ?")) {
    console.log("Implement save functionality here");
  }
}
}

View solution in original post

3 REPLIES 3

VigneshMC
Mega Sage

Try this

HTML

  <div class="btn_save">
        <button type= "submit" class = "button" class="save_form" ng-click="clickMethod()">Save</button>
      </div>

Client script

function($scope) {
  /* widget controller */
  var c = this;
	
	$scope.clickMethod = function () {
	alert("Function called");
  if(confirm("Are you sure to delete ?")) {
    console.log("Implement save functionality here");
  }
}
}

DrewW
Mega Sage
Mega Sage

spModal has a confirm method you can use also

function($scope, spModal) {
		spModal.confirm("Are you sure you wish to copy this?").then(function(confirmed) {
			if(confirmed){
				//Your code if confirmed.
			}
		})

}

srevinU
Kilo Contributor

Thank you for your return, 

Now, I'm trying to run the function regarding the action button selected:

c.clickMethodSave = function(){
		spModal.open({
			title: 'Save Window',
			widget: 'b1691378db5180108fe230d8689619a6',
			buttons: [
				{label: '${Yes}', yes: true},
				{label:'${No}', cancel: false}
			]
		}).then(function(){
			
			//if (yes selected) {then ...}
                        //if (no selected) {then ...}
		})

How can I handle the both condition ? Or more exactly where is the boolean set once the button is selected ?