- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 06:26 PM
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
Solved! Go to Solution.
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 07:57 AM
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?:
Cheers!
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 04:45 PM
Thanks . How to pass the yes/no values to the table from widget.
- 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