I have been looking at all sorts of discussions concerning how to use promises, and I am not getting anything to work.
I keep getting an error "Cannot read property then of undefined."
Is the "then," "done," etc. built-in to Javascript? Or do they require me to include some other external script?
Here is my most recent attempt to experiment with 2 simple dialogs (confirm and reject are both simple dialogs):
var confirmWithPromise = Confirm();
var reject = confirmWithPromise.then(Reject("This record cannot be deleted."));
If I could just get started with the simplest way of getting my example to work, I think I could take it from there.
Thanks.
Update: Here is my Confirm() - which is not returning a promise. I don't fully understand how to implement the return of it:
function Confirm() {
var buttons = [
{
text: "Yes",
//icons: {
// primary: "ui-icon-heart"
//},
click: function () {
$(this).dialog("close");
callback(true);
}
// Uncommenting the following line would hide the text,
// resulting in the label being used as a tooltip
//showText: false
},
{
text: "No",
//icons: {
// primary: "ui-icon-heart"
//},
click: function () {
$(this).dialog("close");
callback(false);
}
// Uncommenting the following line would hide the text,
// resulting in the label being used as a tooltip
//showText: false
}
];
showDialog("Confirm", "Are you sure? Once the record is deleted, it cannot be recovered.", buttons);
}