JQUERY Dialog Integration

Hi,

i’m using Jquery Dialog component to open DHTMLxScheduler, like this:

function open_calendar(id_user){
$("#calendar").dhx_scheduler({

scheduler.load(“events.php?id_user=”+id_user+"");
var dp = new dataProcessor(“events.php?id_user=”+id_user+"");
});
}

the problem is when i create an event on the first call to the function, it works, but if i close the jquery dialog and open another time my function and create an event, it is created twice. I suppose this happens because i open sheduler several times (i call my function several times) and there is a conflict between jquery dialog content and dhtmlxscheduler.

do you have an idea ?

thank you

Sounds like more of a problem with logic than the scheduler itself. You should only instantiate the scheduler once and just have a div open or hide every time you invoke your jQuery item.

yes i could, thanks, but i really want to use jquery dialog component to open scheduler instance. the problem seems because when you open jquery dialog, some code is generated and i think this code is not deleted after closing and there is double code after re-opening.
the only way to make it works is to refresh the page after each action made in the scheduler.

You can still do that without creating a new instance of the scheduler every single time you click the button. Literally, use:

$('#schedulerContainer').show();

or

$('#schedulerContainer').hide();

…where ‘#schedulerContainer’ is the div of your scheduler that you should define only once, probably inside the document.ready function.

Again, the reason it’s behaving the way you described it is because you’re telling the code to create a new instance of the scheduler, without you realizing that that’s the case. Try my suggestion and see if you still encounter the same problem.

In your open function, load the new data with the new user_id you want, and then show your div. But don’t instantiate the scheduler again.

You can invoke the clearAll function in your open window code prior to loading new data, or you can do it on your close window code.

Thank you for your answer. I tried but i still have the problem.

i attached you my index2.php (zipped) if you want to see (i deleted all the code which doesn’t concern scheduler to clean as well as possible).

to explain more:

  • i load in jquery a php file which list me all my computers
  • i declare the scheduler only one time (function init_calendar)
  • on each computer you can click to open a calendar (i pass several parameteres to my function)
  • on this function i have to change scheduler settings (sections and events because i have to put hidden parameters (id_pod and id_rep) in order to send them to my database

the first time i create : ok, but when i call again my function, it loads good events, but when i create i have a js error and it duplicate events in my database

i make probably something wrong but i don’t know where…

thanks in advance !
index2.zip (3.41 KB)