I have added a button to my lightbox that opens a dhtmlxwindow with a seperate event calendar. This works fine on existing events. However when I create a new event and use the button to open a second window then the lightbox hangs. Can not save or close it. Javascript error reported is " b is undefined "
and use the button to open a second window
Do you have 2 open lightboxes in the same time? Scheduler will not work if you are opening new lightbox before closing the first one.
If you have a single lightbox and issue still occurs - can you provide a live demo of the problem ?
No I am not opening a 2nd lightbox. - Upon creating a new event a lightbox is opened. This is a Room Booking. I have a button in the Lightbox which I click and it opens a dhtmlxwindow which then shows me my employee shift schedules for the week. Now when I try to Save or Cancel the lightbox, it does not respond. Even if I close the dhtmlxwindow the lightbox still does not respond. Javascript error: " b is undefined "
Although I thought I had tried this a number of times previously setting scheduler.endlLightbox(false) now seems to work. Lightbox does not hang.
Also, Is there a way to get the selected id in a custom field in the Lightbox prior to saving the lightbox.
I currently use scheduler.getEvent(id).UserID which gives me the UserID for the selection that was last saved from the lightbox. However I would like to be able to choose a different user from the custom field in the Lightbox and then click my Shift Schedule button and pass the UserID from the currently selected custom field to the URL of the dhtmlxwindow being opened. scheduler.getEvent(id).UserID gives me the last saved UserID not the UserID that I just selected from the custom field.
If you are using native lightbox you can use api
scheduler.formSection(name).getValue();
to get currently selected value.
If you are using a custom lightbox - access to its data is beyond scheduler’s functionality.
Thank-you that works great.
Sorry I am mistaken on my original problem. It still does not work for a newly created event. If I create a new event and click my custom section button to open a dhtmlxwindow I immediately get the javascript error " b is not defined ". The lightbox is then hung. Can not save, cancel etc.
Works perfectly fine for an event that has been previously saved.
I simplified my script down to test it. Here is a simple example which simply opens an empty dhtmlxwindow. If I click this button from the Lightbox on a newly created event it gives me the " b is not defined " error and the Lightbox is hung. If I click this button on an event that has been previously saved it works fine.
scheduler.locale.labels.button_Parent = “Open Parent”;
scheduler.form_blocks.textarea.button_click=function(index, src, sec, data) {
dhxWins=new dhtmlXWindows();
var win=dhxWins.createWindow("LinkWin",20,50,920,400);
dhxWins.window("LinkWin").setText("Parent Window");
win.setMinDimension(920,400);
scheduler.endLightbox(false);
win.bringToTop();
}
OK I figured it out
if I remove the scheduler.endLightbox(false) from the script if works.
I thought this had to be set when opening a window. What is the function of this command?
scheduler.endLightbox(false)
It signals that edit operation for event is finished, event can be repainted, and changed data can be sent to the server side ( onEventChanged | onEventAdded handlers will be triggered )
So in what circumstance would you set this to false or true?
So now that I have removed the endLightbox I can now close the lightbox but I can not interact with the dhtmlxwindow. So the endLightbox function is to remove the modal cover to allow me to work with my newly opened window while the Lightbox is still open. OK that works fine while editing a already saved event.
However when creating a new event the endLightbox command causes an error. Please explain how to use this correctly?
Also Please explain where you would use the false setting as opposed to the true setting.
endLightbox can accept html node as parameter - in such case it will hide it ( can be used with custom lightbox html container )
If issue still occurs - please provide a working sample, or demo link
If you want to hide something and end event editing
scheduler.endLightbox(node);
if you want to end event editing and do not want any other changes
scheduler.endLightbox(false);
No this does not solve the problem.
I have set scheduler.endLightbox(false) which works correctly when I am editing an existing event. I click my “Work Shift” button in the lightbox which opens the dhtmlxwindow with my employee shifts and endLightbox(false) removes the modal cover so I can then work with my window and then go back and edit the lightbox and save.
However If I try the same thing with a newly created event the lightbox hangs with the error b is not defined. Please try this and let me know if this works for you.
Create a new event. Open an dhtmlxwindow from a custom button in the lightbox. Then click Cancel on the lightbox. The lightbox will be hung.
Below is my init() function
function init() {
<?if ($BookEditor!=1) {?>scheduler.config.readonly=true;<?}?>
scheduler.locale.labels.unit_tab = "Group"
scheduler.locale.labels.section_custom="Group Resource";
scheduler.locale.labels.section_custom2="WorkGroup Operator";
scheduler.config.details_on_create=true;
scheduler.config.details_on_dblclick=true;
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.config.prevent_cache = true;
scheduler.config.first_hour=0;
scheduler.config.scroll_hour=8;
scheduler.config.hour_size_px=70;
scheduler.config.event_duration=60;
scheduler.config.auto_end_date=true;
scheduler.config.multi_day=false;
scheduler.config.start_on_monday=false;
scheduler.keys.edit_save=27
scheduler.config.agenda_end=scheduler.date.add(new Date(), 1, "month");
scheduler.locale.labels.section_recur="Repeat Event";
scheduler.locale.labels.section_checkme = "Booking Cancelled";
scheduler.config.icons_select=["icon_evshift","icon_details","icon_edit","icon_delete"];
//Add Open Work Shift button to Side Panel
scheduler.locale.labels["icon_details"]="Open Details";
scheduler.locale.labels["icon_edit"]="Edit Name";
scheduler.locale.labels["icon_evshift"]="Open Work Shift";
scheduler._click.buttons.evshift = function(id){
dhxWins=new dhtmlXWindows();
var win=dhxWins.createWindow("LinkWin",200,150,920,400);
dhxWins.window("LinkWin").setText("Work Shift - "+RefUser);
win.attachURL(RefLink);
win.setMinDimension(670,350);
dhxWins.window("LinkWin").bringToTop();
return true;
}
//Add Open Work Shift button to Section
scheduler.locale.labels.button_Shifts = "Open Work Shift";
scheduler.form_blocks.textarea.button_click=function(index, src, sec, data) {
RefUser=scheduler.formSection("custom2").getValue()
if (RefUser=="None") {
RefUser="";
RefLink="Shifts.php?Nav=<?echo $Nav?>&Day="+EventDate;
}
else {RefLink="Shifts.php?View="+RefUser+"&Day="+EventDate;}
if (RefLink) {
dhxWins=new dhtmlXWindows();
var win=dhxWins.createWindow("LinkWin",200,150,920,400);
dhxWins.window("LinkWin").setText("Work Shift - "+RefUser);
win.attachURL(RefLink);
win.setMinDimension(670,350);
dhxWins.window("LinkWin").bringToTop();
scheduler.endLightbox(false);
}
return true;
}
var locations=[
<?$RoomRow=1;$MoreRooms=",";
while ($brow = mysql_fetch_array($bresult)) {
if ($RoomRow==$Rooms) {$MoreRooms="";}
$RoomRow++?>
{key:"<?echo $brow['ID']?>", label:"<?echo $brow['Name']?>"}<?echo $MoreRooms?>
<?}?>
];
var operators=[
<?$UsersRow=1;$MoreUsers=",";
?>{key:"", label:"None"},<?
while ($urow = mysql_fetch_array($uresult)) {
if ($UsersRow==$Users) {$MoreUsers="";}
$UsersRow++?>
{key:"<?echo $urow['Name']?>", label:"<?echo $urow['Name']?>"}<?echo $MoreUsers?>
<?}?>
];
scheduler.config.lightbox.sections=[
{name:"description", height:60, map_to:"text", type:"textarea" , focus:true, button:"Shifts"},
{name:"custom", height:23, type:"select", options:locations, map_to:"RoomID" },
{name:"custom2", height:23, type:"select", options:operators, map_to:"UserID" },
{name:"checkme", map_to:"Cancelled", type:"checkbox", checked_value: "1", unchecked_value: "0" },
{name:"recur",type:"recurring",map_to:"rec_type",button:"recurring"},
{name:"time", height:72, type:"time", map_to:"auto"}
]
scheduler.createUnitsView({
name:"unit",
property:"RoomID",
list:locations
});
//Get Event Date for Work Shift Button
scheduler.attachEvent("onBeforeLightbox", function (id, node, e){
EventDate=scheduler.getEvent(id).start_date;
return true;
});
//Click opens opening side panel
scheduler.attachEvent("onClick", function (id){
EventDate=scheduler.getEvent(id).start_date;
RefUser=scheduler.getEvent(id).UserID
if (RefUser!='') {
RefLink="Shifts.php?View="+RefUser+"&Day="+EventDate;
}
else {RefLink="Shifts.php?Nav=<?echo $Nav?>&Day="+EventDate};
return true;
});
scheduler.templates.event_text=function(start,end,event) {
var Room=scheduler.getLabel("RoomID", event.RoomID);
var User=scheduler.getLabel("UserID", event.UserID);
if (User=="" & event.UserID!="") User=event.UserID
return "<span style='font-weight: Bold'>"+Room+" - "+User+"</span><br>"+event.text;
}
scheduler.templates.event_bar_text=function(start,end,event) {
var Room=scheduler.getLabel("RoomID", event.RoomID);
var User=scheduler.getLabel("UserID", event.UserID);
if (User=="" & event.UserID!="") User=event.UserID
return "<span style='font-weight: Bold'>"+Room+" - "+User+"</span><br>"+event.text;
}
scheduler.templates.week_agenda_event_text=function(start,end, event) {
var Room=scheduler.getLabel("RoomID", event.RoomID);
var User=scheduler.getLabel("UserID", event.UserID);
if (User=="" & event.UserID!="") User=event.UserID
return Room+" - "+User+"<br>"+event.text;
}
scheduler.templates.lightbox_header=function(start,end,event) {
var Room=scheduler.getLabel("RoomID", event.RoomID);
return Room;
}
scheduler.templates.event_class=function(start,end,event) {
if (event.Cancelled==1)
return "cancel_event";
else
return "";
}
var curdate = new Date()
scheduler.init('scheduler_here',new Date(curdate),"unit");
scheduler.load("php/book_all.php");
//When create new event Set default value for owner field to $username
scheduler.attachEvent("onEventCreated",function(id){
scheduler.getEvent(id).Owner="<?echo $username?>";
if(Project) {scheduler.getEvent(id).Project=Project}
return true;
})
var dp = new dataProcessor("php/book_all.php");
dp.init(scheduler);
}
Can you provide a live-demo link, where issue can be checked? ( you can send it by PM )