Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by John on Nov 03, 2009 00:14
open dhtmlx forum
Howto open the lightbox with a textlink?

I will create a link (New Event) like:

<a href="" onclick="">New event</a>

How can I open the lightbox with a textlink?

Answer posted by Alex (support) on Nov 03, 2009 03:32

The showLightBox(event_id) open details form for a certain event:

<a href="javascript:void(0)" onclick="scheduler.showLightBox(event_id);(event||arguments[0]).cancelBubble=true;">Open lightbox</a>

Answer posted by John on Nov 03, 2009 04:21
Hi Alex,

When I copy-paste your link, it doesn't work. Maybe because I have no event_id value?

What did I wrong?

John
Answer posted by Alex (support) on Nov 03, 2009 05:20
Hello John, 

the provided link opens details form for a certain event. You should pass the necessary event id into showLightbox method.

If you want to add event manually, th method addEvent allows to do that. Please, see details about this method in the documentation:

http://www.dhtmlx.com/dhxdocs/doku.php?id=dhtmlxscheduler:api_method_dhtmlxscheduler_addevent


Answer posted by John on Nov 03, 2009 05:34
Hi Alex,

Thanks. I understand your API AddEvent code, but this doen't open a empty lightbox.

But I'm searching for code that opens a empty lightbox, with default the current date (like the text-hyperlink 'Create event' in Google Calendar)....

John
Answer posted by Alex (support) on Nov 03, 2009 05:50
So.. you need to make changes in the Description block of the lightbox, don't you ?

Lightbox can be customized. Please, have a look at the http://www.dhtmlx.com/dhxdocs/doku.php?id=dhtmlxscheduler:custom_details_form article. Here this functionality is described in detail.
Answer posted by John on Nov 03, 2009 06:37
I'm afraid you don't understand me.

1. I'm only searching for the (api) code for a textlink with the sample name "New event".
2. when anybody clicks on this link, the schedular opens a empty lightbox with default the current date.

Answer posted by Stanislav (support) on Nov 03, 2009 07:04
>>But I'm searching for code that opens a empty lightbox, with default the current date (like the text-hyperlink 'Create event' in Google Calendar)....
If I understood correctly you need to show lightbox for new event, right?

In such case you can use 

var id = scheduler.uid();
scheduler.addEvent({ 
   id:id,
   text:"new event",  
   start_date: new Date(),
   end_date:new Date()
});
scheduler.showLightbox(id);

It will create a new event and will show the details form for it. 
Answer posted by John on Nov 03, 2009 07:11
Thanks, it works!
Answer posted by John on Nov 03, 2009 07:21
uhm, sorry...

It works not correctly.

He inserts a new event in de schedular BEFORE I get the ligtbox.
And then when I type any text in the lightbox and choose a date, he doesn't save my data when I press Save: nothing happens.


Answer posted by Alex (support) on Nov 03, 2009 08:53
>> And then when I type any text in the lightbox and choose a date, he doesn't save my data when I press Save: nothing happens.

what functionality do you use for saving ?
Answer posted by John on Nov 05, 2009 05:06
When I paste your code in a function in a default schedular-sample (05_custum_editor.html), I get this "error":

<script type="text/javascript" charset="utf-8">
function openNewEvent() {
var id = scheduler.uid();
scheduler.addEvent({
   id:id,
   text:"new event", 
   start_date: new Date(),
   end_date:new Date()
});
scheduler.showLightbox(id);
}
</script>
<a onclick="openNewEvent();">New event</a>

Answer posted by John on Nov 05, 2009 05:12
The "save" functions works, but the event is placed in the schedular, when I press my New Event button and see the ligtbox.
Answer posted by Alex (support) on Nov 05, 2009 05:18

>> The "save" functions works, but the event is placed in the schedular, when I press my New Event button and see the ligtbox.

It seems that everything is correct. So, what's wrong with it ? 

Answer posted by John on Nov 05, 2009 05:25
The problem is: When i press on my button New Event, I see the Ligtbox. But when I press Cancel: the event is placed.....

Thats the problem: the event is placed, before I can do anything...

Answer posted by Stanislav (support) on Nov 05, 2009 06:03
Please try to use attached version of js file instead of the original one, it has an extra js command

scheduler.addEventNow();
or
scheduler.addEventNow(new Date(), new Date());

It will create a new event in the same way as it can be done by double-clicking ( it is not saved until form is not closed, and pressing  the cancel button in the form will remove it ) 
Attachments (1)