0

Hi here i want to fire next or prev button click event of jquery full calender. But the click event is not firing am tried several ways it did not fired

$(document).ready(function () {
    $('#contaner_wrapper').css("height", "100%");
    $(".fc-button-prev a span").trigger('click');

    $(".fc-button-next a span").trigger('click');       
    $('.fc-button-prev a span').click(function () {
        alert($("#calendar").fullCalendar('getView').start.toString());

        var abc = $("#calendar").fullCalendar('getView').start.toString();

        var ab = $("#calendar").fullCalendar('getView').end.toString();
        // Displaymonthevents();
    });

    $('.fc-button-next a span').click(function () {
        // Displaymonthevents();
        alert($("#calendar").fullCalendar('getView').start.toString());
        var abc = $("#calendar").fullCalendar('getView').start.toString();

        var ab = $("#calendar").fullCalendar('getView').end.toString();
    });

});
2
  • 1
    are these element dnamically loaded Commented Jun 18, 2013 at 4:51
  • Yes, those loading dynamically Commented Jun 18, 2013 at 4:54

3 Answers 3

1

The problem could be, you are using fullcalendar and these elements are created by fullcalendar plugin, so when this script is executed there is a possibility that the plugin may not have yet created. Which means the event handlers will not get registered.

So the solution is to make use of event delegation

$(document).ready(function () {
    $('#contaner_wrapper').css("height", "100%");
    $(document).on('click', '.fc-button-prev a span', function () {
        alert($("#calendar").fullCalendar('getView').start.toString());

        var abc = $("#calendar").fullCalendar('getView').start.toString();

        var ab = $("#calendar").fullCalendar('getView').end.toString();
        // Displaymonthevents();
    });

    $(document).on('click', '.fc-button-next a span', function () {
        // Displaymonthevents();
        alert($("#calendar").fullCalendar('getView').start.toString());
        var abc = $("#calendar").fullCalendar('getView').start.toString();

        var ab = $("#calendar").fullCalendar('getView').end.toString();
    });

    $(".fc-button-prev a span").trigger('click');
    $(".fc-button-next a span").trigger('click');       
});
Sign up to request clarification or add additional context in comments.

5 Comments

here i want to call web method or page method. $(document).on('click', '.fc-button-prev a span', function () { PageMethods.EventDetails('E72', onSucess, onError); }); but its not firing
what is PageMethods.EventDetails?
PageMethods.EventDetails('E72', onSucess, onError); }); is a pagemethod when this click event is firing.or insted of pagemethod i want to call ajax web method. any one is fine for me $.ajax({ url: "ViewEvents.aspx/EventDetails", type: "POST", data: "hi", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { alert(data.d); } });
is it ASP? I haven't used it
yes it is asp.net,but any one is fine for me either ajax web method or page method. please refer this link stackoverflow.com/questions/17160947/…
0

Assuming that you put the code in the same order as your web page, I think you just need to do the trigger after you register the click handler.

Here is a JS Fiddle that does what I think you are asking for:

http://jsfiddle.net/Td5cG/1/

$('.fc-button-prev a span').click(function () {
    alert("clicked it");
});

$(".fc-button-prev a span").trigger('click');

Comments

0

use .live() - old version or .on() - new vesion. Example:

$(".fc-button-prev a span").live('click', function(){ alert($("#calendar").fullCalendar('getView').start.toString()); })

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.