New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar "onMonthLoaded" not being triggered after clicking on month/year list #336

Closed
shamank opened this Issue Jul 23, 2015 · 7 comments

Comments

Projects
None yet
2 participants
@shamank
Copy link

shamank commented Jul 23, 2015

It works as expected if tapping or touching month/year handler buttons, but not if you select from the list that appears if you touch the month/year label. This is the only method I found for doing what I need to do (attach an event every time the month/year change) :( is there any workaround for this? Thanks!

Example:

$(el).mobiscroll().calendar({
    onMonthLoaded: function () { console.log("ADASD"); }
});

yes

no

@dioslaska

This comment has been minimized.

Copy link
Contributor

dioslaska commented Jul 24, 2015

Thanks for the report, I was able to reproduce it.
The onMonthChange event however fires correctly. Maybe you can use that for what you are doing.

@shamank

This comment has been minimized.

Copy link

shamank commented Jul 24, 2015

Yes, but the onMonthChange event doesn't fire if you change the year (current month is refreshed according to the new year selected but the onMonthChange event is not fired). Maybe because the triggering condition is waiting for a change of name. Thanks.

@dioslaska

This comment has been minimized.

Copy link
Contributor

dioslaska commented Jul 24, 2015

What version are you using? I'm testing with 2.16.1 and the onMonthChange event fires when changing the year as well.

@shamank

This comment has been minimized.

Copy link

shamank commented Jul 24, 2015

Yes, sorry, you are right (2.16.1). The problem is that when changing the year and firing the event, in that moment the datagrid is not yet loaded (as opposite, it is when changing the month). I'm attaching material design events to buttons (via js) so I need to attach them after the buttons were already parsed by JQM.

Debugger paused in console.log():
1

Resuming:
2

@dioslaska

This comment has been minimized.

Copy link
Contributor

dioslaska commented Jul 24, 2015

Here's a workaround until it gets fixed. The navigate method needs to be overridden / extended to trigger the onMonthLoaded method:

    $('#calendar').mobiscroll().calendar({
        onMonthLoaded: function () {
            console.log('load');
        },
        onInit: function (inst) {
            if (!inst._navigate) {
                inst._navigate = inst.navigate;

                inst.navigate = function (d, anim) {
                    var s = inst.settings;
                        y = s.getYear(d),
                        m = s.getMonth(d),
                        visible = inst.isVisible();

                    // Call original function
                    inst._navigate(d, anim);

                    if (!anim && visible) {
                        inst.trigger('onMonthLoaded', [y, m]);
                    }
                };
            }
        }
    });
@shamank

This comment has been minimized.

Copy link

shamank commented Jul 24, 2015

Thank you!

@dioslaska dioslaska added this to the 2.17.0 milestone Aug 12, 2015

@dioslaska

This comment has been minimized.

Copy link
Contributor

dioslaska commented Aug 25, 2015

Fixed, will be released in 2.17.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment