unit view - onEmptyClick - addEventNow conflict

In order to run a simple scheduler on the ipad as well, I needed to get rid of the double click when clicking on an existing event and also when creating a new one.
So I added something like the following to my client side:

	scheduler.attachEvent("onClick", function(id, e){
		scheduler.showLightbox(id);
	});
	scheduler.attachEvent("onEmptyClick", function(id, e){
		scheduler.addEventNow(id);

	});

It works fine like that, however, I’ve added a unit view and have the problem that when I click to create a new event in the unit view, the new event is created in the most left-side column n matter which column I click in. If I remove the above attachEvent onEmptyClick code, then double click in the unit view to create a new event, it works as it should and gets created in the column (section) that I clicked in. Somehow, adding the attachEvent onEmptyClick turns off that nice feature.
I’ve looked at some of the solutions in the forum for similar issues but they don’t work.
I could really use some help!
Thanks in advance,
Irv

Hello,

scheduler.attachEvent("onEmptyClick", function(id, e){

First argument there is not id but date.

To correctly create event using addEventNow on view which supports units/resources you need to pass whole object with correct data: start_date, end_date, your_section_id.

var action_data = scheduler.getActionData(e); var event = { start_date: action_data.date, end_date: scheduler.date.add(action_data.date, 5, "minute"), your_section_id: action_data.section }; scheduler.addEventNow(event);
Kind regards,
Ilya

Outstanding - thank you so much (I’m a noob at this).
Note that I have two views with different section_id’s. I did the following -
scheduler.attachEvent(“onEmptyClick”, function(id, e) {
var action_data = scheduler.getActionData(e);
var event = {
start_date: action_data.date,
end_date: scheduler.date.add(action_data.date, 5, “minute”),
your_section1_id: action_data.section,
your_section2_id: action_data.section
};
scheduler.addEventNow(event);
});
I works generally, but every once in a while, the select list drop-down the of the section_id that is not associated with the current unit view shows up blank in the lightbox (the options are there but the default is blank). Ideas?
Irv

Don’t set both of them with the same value.
You can check what view you are on with:
scheduler.getState().mode
e.g.

if (scheduler.getState().mode == "unit") { ...
Best regards,
Ilya

Great, it’s clean now. Again, thanks.
On another note, I just gave it a quick test on an iPad, and the onEmptyClick works great. But I didn’t realize that the single click on an existing event doesn’t work (lightbox associated with the event doesn’t open up). I guess that I was so focused on the onEmptyClick that I didn’t check if the following works on the iPad -
scheduler.attachEvent(“onClick”, function(id, e){
scheduler.showLightbox(id);
});
Is there something that can be done for that?
Irv.

BTW, for anyone following this -
in addition to checking which unit view you’re in, you also should add a check to whether you’re not in a unit view. Otherwise the non-unit views will exhibit a similar behavior (i.e. - date will default to incorrect value - earliest available). I guess that’s sort of programming 101.

Again, Ilya, if you can help me with a fix for onClick (single click for event creation) in the iPad environment, that would be great.
Thanx,
Irv

Just had a duh moment on the onClick single click on an iPad. I have tooltips enabled and that’s obviously incompatible with the iPad situation. Works fine if I disable tooltips.
Irv.