Here I have a table with two column. In 1st is draggable div object so:
$(function() {
$( "div.available" ).draggable({
snap: "div.timeline-axis-grid"
});
});
and in 2nd column is timeline table based on google visualisation API. http://jsbin.com/oLaqoToH/5
You will see when make double click on timeline table then you create a new div object into timeline.
Now I want to simulate double click when I end dragging object from 1st column to timeline. So simple I want to add a div object from 1st column to timeline with this little hack. Is there any way to do this? Is this possbile to use with jquery? How I can simulate dobuleclick on draggable ending?
UPDATE: I dont need to simulate double clikc becouse this action has an function:
http://almende.github.io/chap-links-library/js/timeline/timeline.js
/**
* Double click event occurred for an item
* @param {Event} event
*/
links.Timeline.prototype.onDblClick = function (event) {
var params = this.eventParams,
options = this.options,
dom = this.dom,
size = this.size;
event = event || window.event;
if (params.itemIndex != undefined) {
var item = this.items[params.itemIndex];
if (item && this.isEditable(item)) {
// fire the edit event
this.trigger('edit');
}
}
else {
if (options.editable) {
// create a new item
// get mouse position
params.mouseX = links.Timeline.getPageX(event);
params.mouseY = links.Timeline.getPageY(event);
var x = params.mouseX - links.Timeline.getAbsoluteLeft(dom.content);
var y = params.mouseY - links.Timeline.getAbsoluteTop(dom.content);
// create a new event at the current mouse position
var xstart = this.screenToTime(x);
var xend = this.screenToTime(x + size.frameWidth / 10); // add 10% of timeline width
if (options.snapEvents) {
this.step.snap(xstart);
this.step.snap(xend);
}
var content = options.NEW;
var group = this.getGroupFromHeight(y); // (group may be undefined)
var preventRender = true;
this.addItem({
'start': xstart,
'end': xend,
'content': content,
'group': this.getGroupName(group)
}, preventRender);
params.itemIndex = (this.items.length - 1);
this.selectItem(params.itemIndex);
this.applyAdd = true;
// fire an add event.
// Note that the change can be canceled from within an event listener if
// this listener calls the method cancelAdd().
this.trigger('add');
if (this.applyAdd) {
// render and select the item
this.render({animate: false});
this.selectItem(params.itemIndex);
}
else {
// undo an add
this.deleteItem(params.itemIndex);
}
}
}
links.Timeline.preventDefault(event);
};
How I can use this function to drag object to timeline instead to use doubleclick simulation??? Thanks!