onBeforeDrag to prevent drag the past events

Hi all.
There is the possibility of prevent the dnd of the past events?
I don’t understand how to use the function onBeforeDrag with the date.

Thank you.

Check the next extension
docs.dhtmlx.com/doku.php?id=dhtm … collisions

I want the possibility of block or readonly state of an event if the event is old event,
the follow function work fine:
scheduler.templates.event_class=function(start,end,event){
if (start < (new Date()))
return “past_event”;
}
I try:
scheduler.attachEvent(“onBeforeDrag”,function(start,end,event){
if (start < (new Date())) {
alert(“bla bla”);
return false;
}
return true;
})

but not work

Thank You very much.

Try to change it as

scheduler.attachEvent("onBeforeDrag",function(ev){
  if (ev.start_date < (new Date())) {
    alert("bla bla");
    return false;
  }
  return true;
})

Hi thank you for answer but NO effect.
Strange but not work.
my JS:

Thank you very much

Sorry, with your suggestion I have an error:
I can’t insert a new event.
Error: expected object - dhtmlxscheduler_units.js.
start_date is null o isn’t a object.

Sorry for inconvenience, was a my error

Correct code must look as

scheduler.attachEvent("onBeforeDrag",function(id){ var ev = scheduler.getEvent(id); if (ev && ev.start_date < (new Date())) { alert("bla bla"); return false; } return true; })

Thank you very very much.
This Work perfectly.

Sondra

Hi Stanislav.
This code work very well:

scheduler.attachEvent(“onBeforeDrag”,function(id){
var ev = scheduler.getEvent(id);
if (ev && ev.start_date < (new Date())) {
alert(“bla bla”);
return false;
}
return true;
})

Now I want control one value of DB for prevent dnd, example:

scheduler.attachEvent(“onBeforeDrag”,function(id){
var ev = scheduler.getEvent(id);
if (ev && ev.some_column = 1) {
alert(“bla bla”);
return false;
}
return true;

but not work.

Can you help me?

Thank You

Sondra

May be it is just a typo, but valid code will be

 if (ev && ev.some_column == 1) {  // ==

All other looks correct, just be sure that you have included “some_column” in list of fields of server side connector’s code.

Thank you Stanislav.
Work very well, I forget ==

This is the working code:

scheduler.attachEvent(“onBeforeDrag”,function(id){
var ev = scheduler.getEvent(id);
if (ev && ev.some_column == 1) {
alert(“Bla Bla Bla”);
return false;
}
return true;
})

Thank you
Sondra