|
// Additional argument passed to perform button disable
function getDialogButtons(action, enable) {
var primaryButtonClass = action === 'Delete' ? 'e-dialog-yes' : action === 'Add' ? 'e-dialog-add' : 'e-dialog-edit';
var flatButtonClass = action === 'Delete' ? 'e-dialog-no' : 'e-dialog-cancel';
var dialogButtons =
[
{
buttonModel: {
cssClass: 'e-flat ' + primaryButtonClass, isPrimary: true,
content: action === 'Add' || action === 'Edit' ? 'Save' : 'Yes',
disabled: (enable == true) ? false : true // Enable/Disable the button based on condition
},
type: action === 'Add' || action === 'Edit' ? 'submit' : 'button',
click: dialogButtonClick.bind(this)
}, {
buttonModel: {
cssClass: 'e-flat ' + flatButtonClass, isPrimary: false,
content: action === 'Add' || action === 'Edit' ? 'Cancel' : 'No'
},
click: dialogButtonClick.bind(this)
}
];
return dialogButtons;
}
passwordInputElement.addEventListener('keyup', function () {
if (passwordInputElement.value != "") {
// Reassign new buttons value
dlgObj.buttons = getDialogButtons(dialogType, true);
dlgObj.dataBind();
}
});
|
Hi Arshad,Greetings from Syncfusion support.We have validated your requirement and it can be achievable by changing buttons -> buttonModel -> disabled property dynamically and updating the buttons property in application end.In the above sample, we configure keyup event to password input field which placed inside the dialog. On keyup event callback, we call getDialogButtons() method and assigned the result value into buttons API.Sample code block
// Additional argument passed to perform button disablefunction getDialogButtons(action, enable) {var primaryButtonClass = action === 'Delete' ? 'e-dialog-yes' : action === 'Add' ? 'e-dialog-add' : 'e-dialog-edit';var flatButtonClass = action === 'Delete' ? 'e-dialog-no' : 'e-dialog-cancel';var dialogButtons =[{buttonModel: {cssClass: 'e-flat ' + primaryButtonClass, isPrimary: true,content: action === 'Add' || action === 'Edit' ? 'Save' : 'Yes',disabled: (enable == true) ? false : true // Enable/Disable the button based on condition},type: action === 'Add' || action === 'Edit' ? 'submit' : 'button',click: dialogButtonClick.bind(this)}, {buttonModel: {cssClass: 'e-flat ' + flatButtonClass, isPrimary: false,content: action === 'Add' || action === 'Edit' ? 'Cancel' : 'No'},click: dialogButtonClick.bind(this)}];return dialogButtons;}passwordInputElement.addEventListener('keyup', function () {if (passwordInputElement.value != "") {// Reassign new buttons valuedlgObj.buttons = getDialogButtons(dialogType, true);dlgObj.dataBind();}});If you still facing any other issue, kindly revert to us.Regards,Pandiyaraj
|
// Bind created event
var dlgObj = new ej.popups.Dialog({
created: dialogCreated
});
dlgObj.appendTo("#dialog");
// Bind keyup event to dialog inside placed input elements
function dialogCreated() {
var textEle = dlgObj.element.querySelectorAll(".e-dlg-content .e-input");
for (var i = 0; i < textEle.length; i++) {
textEle[i].addEventListener("keyup", onKeyUp);
}
}
|