modal dialog

Raji9
Tera Expert

 

HI All,

 

Modal dialog is not opening when button is clicked in the widget..   I copied the HTML code and client script. Do I  miss any other code here...

//HTML template
<button ng-click="c.onAgree()" class="btn btn-default">
    Agree
  </button>
  <div ng-show="c.agree">
    You answered {{c.agree}}
  </div>

//Client script
function(spModal) {
  var c = this;
  c.onAgree = function() {
        // ask the user for a string
        // note embedded html in message
        var h = '<h4>Apple likes people to agree to lots of stuff</h4>'
        // Line feeds added to the following lines for presentation formatting.
        var m = 'Your use of Apple software or hardware products is based 
on the software license and other terms and conditions in effect for the 
product at the time of purchase. Your agreement to these terms is required 
to install or use the product. '
        spModal.open({
            title: 'Do you agree?',
            message: h + m,
            buttons: [
                {label:'✘ ${No}', cancel: true},
                {label:'✔ ${Yes}', primary: true}
            ]
        }).then(function() {
            c.agree = 'yes';
        }, function() {
            c.agree = 'no';
        })
    }
}

 

Thanks

Raji

1 ACCEPTED SOLUTION

Martin iTSM
Tera Guru

I`m not that much into widget development, but with this you would get the yes/no value to the server and can do with with it whatever you want (although this can be done in a more sophisticated way i guess ;-)) - eg. log, update any record/table value etc.:

// HTML
<button ng-click="c.onAgree()" class="btn btn-default">
  Agree
</button>
<div ng-show="c.data.agree">
  You answered {{c.data.agree}}
</div>

// Client Script
function(spModal) {
	var c = this;
	c.onAgree = function() {
		// ask the user for a string
		// note embedded html in message
		var h = '<h4>Apple likes people to agree to lots of stuff</h4>'
		// Line feeds added to the following lines for presentation formatting.
		var m = 'Your use of Apple software or hardware products is based on the software license and other terms and conditions in effect for the product at the time of purchase. Your agreement to these terms is required to install or use the product. '
		spModal.open({
			title: 'Do you agree?',
			message: h + m,
			buttons: [
				{label:'✘ ${No}', cancel: true},
				{label:'✔ ${Yes}', primary: true}
			]
		}).then(function() {
			c.data.agree = 'yes';	
			c.server.update();
		}, function() {
			c.data.agree = 'no';			
			c.server.update();
		})
	}
}

// Server Script
(function(spUtil) {
	/* populate the 'data' object */
	/* e.g., data.table = $sp.getValue('table'); */	
	
	if (input) {		
		if (input.agree == 'yes') {
			// Do whatever you need here instead of logging
			console.log('I`m fine with that!');			
		} else if (input.agree == 'no') {
			// Do whatever you need here instead of logging
			console.log('Nooooo way!');
		}		
	}
})();

However; hope it helps.

Regards!

Martin

View solution in original post

3 REPLIES 3

Martin iTSM
Tera Guru

Hey there,

copied your code and created a new widget - works like a charm in Widget Editor.
Only thing i had to correct was the line breaks for variable "m" as SN marked the breaks with red underlines showing that there`s some issue with that.

But the rest seems fine to me - does your browser block popups maybe?:

MartiniTSM_0-1707839792768.png

 

Cheers!

Martin

Raji9
Tera Expert

Thanks  . How to pass the yes/no values to the table from widget.

 

Martin iTSM
Tera Guru

I`m not that much into widget development, but with this you would get the yes/no value to the server and can do with with it whatever you want (although this can be done in a more sophisticated way i guess ;-)) - eg. log, update any record/table value etc.:

// HTML
<button ng-click="c.onAgree()" class="btn btn-default">
  Agree
</button>
<div ng-show="c.data.agree">
  You answered {{c.data.agree}}
</div>

// Client Script
function(spModal) {
	var c = this;
	c.onAgree = function() {
		// ask the user for a string
		// note embedded html in message
		var h = '<h4>Apple likes people to agree to lots of stuff</h4>'
		// Line feeds added to the following lines for presentation formatting.
		var m = 'Your use of Apple software or hardware products is based on the software license and other terms and conditions in effect for the product at the time of purchase. Your agreement to these terms is required to install or use the product. '
		spModal.open({
			title: 'Do you agree?',
			message: h + m,
			buttons: [
				{label:'✘ ${No}', cancel: true},
				{label:'✔ ${Yes}', primary: true}
			]
		}).then(function() {
			c.data.agree = 'yes';	
			c.server.update();
		}, function() {
			c.data.agree = 'no';			
			c.server.update();
		})
	}
}

// Server Script
(function(spUtil) {
	/* populate the 'data' object */
	/* e.g., data.table = $sp.getValue('table'); */	
	
	if (input) {		
		if (input.agree == 'yes') {
			// Do whatever you need here instead of logging
			console.log('I`m fine with that!');			
		} else if (input.agree == 'no') {
			// Do whatever you need here instead of logging
			console.log('Nooooo way!');
		}		
	}
})();

However; hope it helps.

Regards!

Martin