0

i want to trigger left mouse click on right click. when user enter right click on text so at same place or at same mouse coordinate where trigger left click.

i don't want to trigger by id. like. and i also try this method.

$('.foo').trigger('click');

i want to trigger at same place where mouse cursor exists or by mouse coordinate.

actually i'm using full calendar so when user right click on calendar, so at same place trigger left click, then i get date by left click.

user2511667
  • 153
  • 1
  • 4
  • 13

1 Answers1

2

Updated

This code enables both right clicking on events as well as right clicking on day slots:

$("#calendar").mousedown(function (e) {
    if (e.button === 2) {
        if($(e.target).parents(".fc-event").length > 0) return;

        var newEvent = $.extend($.Event("mousedown"), {
            which: 1,
            clientX: e.clientX,
            clientY: e.clientY,
            pageX: e.pageX,
            pageY: e.pageY,
            screenX: e.screenX,
            screenY: e.screenY

        });
        $(e.target).trigger(newEvent);

    }
});

$("#calendar").mouseup(function (e) {
    if (e.button === 2) {
        if(!$(e.target).parents(".fc-event").length > 0) return;

        var newEvent = $.extend($.Event("click"), {
            which: 1,
            clientX: e.clientX,
            clientY: e.clientY,
            pageX: e.pageX,
            pageY: e.pageY,
            screenX: e.screenX,
            screenY: e.screenY

        });
        $(e.target).trigger(newEvent);

    }
});

A full example is available here: http://jsfiddle.net/kvakulo/KEJYD/2/

Regin Larsen
  • 1,152
  • 8
  • 14
  • In month view it is working but in week view or day view it is not working... it return invalid date in week or day view.... and in week view or day view on click date is return but on trigger it return invalid date. its working fine in month view... – user2511667 Jul 10 '13 at 11:24
  • I've updated my answer with inspiration from http://stackoverflow.com/a/12572571/198065. This seems to work better in the different views of FullCalendar. – Regin Larsen Jul 10 '13 at 12:01
  • Thank you thank you soooooooooooooooooo much. its work... i just change mousedown to click in link 3 – user2511667 Jul 10 '13 at 12:09
  • Dear sir it is work perfect in chrome,but it is totally not work in Mozilla, Please tell me more what can i do? why its not work in mozilla, – user2511667 Jul 10 '13 at 12:16
  • 1
    You are welcome. I have updated my answer accordingly. Please would mark it as an answer? – Regin Larsen Jul 11 '13 at 07:38
  • please sir could you tell me how can i add context menu in which... i try to add context menu but i'm fail... my context menu is show on every where on calendar e.g scroll bar, prev next button etc, but i want to show it only on day slot... please help me.. – user2511667 Jul 19 '13 at 10:25
  • I've been looking everywhere for this... absolutely BRILLIANT work! Yes, this should be marked as the answer! – Awerealis Apr 16 '14 at 03:59