Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 03:09 AM
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