kthornbloom / Monthly

A jQuery based responsive calendar
http://kthornbloom.com/monthly/
Other
316 stars 108 forks source link

Is there any way to add event data as a resource instead of passing json or xml files? #57

Closed NitishKumarPatra closed 7 years ago

NitishKumarPatra commented 7 years ago

I am looking for a solution to pass the data dynamically to the calendar view.but it always requires a file object to render the events. How do i pass the values dynamically ?

LinkBenjamin commented 7 years ago

https://github.com/kthornbloom/Monthly/issues/32

This closed thread might help you. I pass in the results of a RESTful service to my calendar object.

NitishKumarPatra commented 7 years ago

Thank u @LinkBenjamin for your quick reply. What i see is that the jsonUrl we pass as a parameter generally requires a filepath. You are still Passing [ jsonUrl: '/api/public/eventcalendar' ] in the closure. I am planning to make an Ajax call to a Controller. How do you intercept the issue? Will that work?

LinkBenjamin commented 7 years ago

The filepath is actually a URL. I just used a relative path rather than absolute:

http://www.mywebsite.com/api/public/eventcalendar would work just fine in that field, assuming that you had a controller mapped to respond from there.

NitishKumarPatra commented 7 years ago

Thanks @LinkBenjamin ,i will get back once i resolve the issue.

NitishKumarPatra commented 7 years ago

Hi @LinkBenjamin ,it worked well using a ajax route to controller,now i am able to get the events over it. I have got another issue, i want to destroy the calendar instance on a particular button click.Is that possible?Or we have to manually empty() the row/div using jquery?

LinkBenjamin commented 7 years ago

You have to empty() it. Here's the refreshCalendar() method I wrote for my app, based on a series of checkboxes and a dropdown (there's an expiration date and a scheduled update date in my app, and I let the users filter the calendar by either one).

    function refreshCalendar(){
        var dateFilter = $('#dateField').val();

        var selected = new Array();

        $("input:checkbox[name=itemtypelist]:checked").each(function() {
             selected.push($(this).val());
        });

        newid= new Date().getTime();

        $('.monthly').empty().replaceWith('<div class="monthly" id="cal' + newid + '"></div>');
        $('#cal' + newid).monthly({
            mode: 'event',
            jsonUrl: '/api/public/eventcalendar?dateFilter=' + encodeURIComponent(dateFilter) + '&itemtypelist=' + selected,
            dataType: 'json'
        });
    }
NitishKumarPatra commented 7 years ago

@LinkBenjamin Thanks for the guidance, i too had to empty it using jquery,i was using a toggle row for each person's schedule,and empty the remaining others' toggle row view when one is clicked. Wished, this plugin would have come up with a destroy() method. Plus something is very annoying in this plugin is that it has appended url to all anchor tags which i think is not useful, at least in my usage case. It calls for an ajax to run on every click,which repopulates the events one on another on the same month,with same data. I had to rectify it myself. Hope so we get a view option set so that we don't have to many clicks to see the day schedule (like monthly, weekly, or daily view, so that the plugin initiates with the defined view ).