Dynamic lightbox sections

Is it possible to dynamically build the lightbox based on rules? For example, if variable “recurring_allowed” is true then we will include the recurring part of the lightbox. I could also include other optional sections based on the user’s privileges.
Thanks!

Yes, it’s possible to reconfigure ligthbox with resetLightbox method, you can do it every time when lightbox shows up. Something like following:

[code]scheduler.attachEvent(“onBeforeLightbox”, function (event_id){
var config;
if(someCondition){
config = [
{name:“description”, height:200, map_to:“text”, type:“textarea” , focus:true},
{name:“time”, height:72, type:“time”, map_to:“auto”}
];
}else{
config = [
{name:“time”, height:72, type:“time”, map_to:“auto”}
];
}

scheduler.config.lightbox.sections = config;
scheduler.resetLightbox();
return true;

});[/code]
docs.dhtmlx.com/doku.php?id=dhtm … relightbox
docs.dhtmlx.com/doku.php?id=dhtm … etlightbox

Thanks for prompt response Aliksandr.
I’m still not sure how to “build” the config variable though. There could potentially be lots of different versions of the lightbox, depending on several conditions. I need to be able to “append” sections to the lightbox configuration after checking each condition.
Is that possible, or do I need to define all the different possible lightboxes?
Thanks,
Catherine

Sure, lightbox configuration is a regular js array with lightbox controls. You can append these controls conditionally and then assign resulting array to lightbox config.
Something like following:[code]var lb = [];//initial config

if(canEdit)//add text editor
lb.push({name:“description”, height:200, map_to:“text”, type:“textarea” , focus:true});

if(canSetTime)//add time picker
lb.push({name:“time”, height:72, type:“time”, map_to:“auto”});

//apply config
scheduler.config.lightbox.sections = config;
scheduler.resetLightbox();[/code]

Perfect! That’s exactly what I need. Thanks so much. :smiley: