Restrict Dialog Opening Conditionaly through Listener AEM6.1
Hi
I have created a component with design dialog and I want this component to be editable only on base template and not on other templates. For this, I have added a listener to the dialog and in its "render" property I have written below code:
function(box) {
var currentPage = $('#design_basepage').val();
if(currentPage == undefined){
alert('This component can be edit in the Base page only.');
box.close();
}
}
In the above code "design_basepage" is a variable provided in base template. This code works fine for the first time after page refresh(On click of edit in design mode, alert is displayed saying that "it cant be edited in base template"). But second time if we click on edit, no alert is displayed and on checking the console: error is coming as " Type error: el is undefined". It might be happening due to box.close(), but we don't have a solution for it.
Please help.