how click save button after custom button fires in editForm

In mobile scheduler i cannot get the $$(“scheduler”).$$(“editForm”).save(); inside of a custom button onItemClick event.

However, I have pasted code below that I am able to fire the Save button using javascript.

// “checkout” is a button i added to the editForm

$$(“scheduler”).$$(“checkout”).attachEvent(“onItemClick”,function(){
// cycle through to find the dhtmlx element Save button
var inputs = document.getElementsByTagName(‘input’);
var element;
for (var i = 0; i < inputs.length; i ++) {

            if (inputs[i].type == 'button' && inputs[i].value == 'Save') {

          	element = inputs[i];

            }

    }


   var theEvent = document.createEvent("MouseEvent");
   theEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);

// fire a click event in the Save button
element.dispatchEvent(theEvent);

});

so is there another way to do this using dhtmlx api ?

You can call onclick handler for “save” button using callEvent method:

var id =$$(“scheduler”).$$(“save”).config.id;
$$(“scheduler”).callEvent(“onItemClick”,[id]);