Try redefining the _do_paste function after the dhtmlxscheduler_key_nav.js file has been included in your code (this is the function that calls onEventPasted and adds the event), it’s current code should be something similar to:
I wouldn’t recommend redefining internal functions, what if the dhtmlx team change the way that works in the next version? Your app will break.
Instead, you can make use of the onEventPasted function and perhaps implement the following steps within:
set the scheduler to readonly mode and show the loading cover (or implement your own)
Do your checks on the event object that is passed in
If the checks fail, delete the event using scheduler.deleteEvent(id) or kick some other process off such as showing the lightbox where the user can correct the data etc…
If you plan on updating to newer versions then it would be advised to instead make your changes either in a new JS file (making sure to include it after the file that you’re modifying) or solely in your own code in a script tag (like I mentioned). Otherwise you’ll need to go through and apply your changes to the new version of the scheduler when you update.
I’ve been doing this since around V2 of the scheduler with no issues, if something does change it only takes a couple of minutes to check the console log for which function is causing the issue, check over the new versions code for that function and apply the changes to your custom function.
If that method works for you and you haven’t had any issues that’s great. I didn’t mean to come across as negative about your approach, just to offer another perspective for anyone with a similar problem in the future.
In this particular scenario, the method you are overwriting is quite simple and it is unlikely that the dhtmlx team would completely rewrite it in future versions, but I still wouldn’t make that approach a habit.
If there is a clear need to take an existing lib and change the inner workings for your specific needs, this is where you should be forking the code base.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan