nazar-pc / PickMeUp

Really simple, powerful, customizable and lightweight standalone datepicker
BSD Zero Clause License
615 stars 191 forks source link

PickMeUp Problem with Prev and Next #162

Closed abdallahboodhun closed 7 years ago

abdallahboodhun commented 7 years ago

Hi Nazar, I really appreciate your pickmeup plugin. I have integrated the plugin in a project I am working on. What I have done until now is to initialize the plugin and passing some JSON encoded PHP value for the date selection. Here’s my initialization of the plugin: init_Calendar(<?php echo json_encode($newformat);?>,<?php echo json_encode($cal_nid);?>);

function init_Calendar(date,id){ 
                pickmeup('.event-calendar', {
                    flat      : true,
                    date      : date,
                    mode      : 'multiple',
                    calendars : 2,
                    select_year: false,
                    select_month: false,
                    render : function () {
                        return {id : id};
                    }
                });
            }
$('.pmu-selected').click(function(){ 
                var nid = $(this).attr('id');
                arr_calendar = <?php echo json_encode($cal_data);?>;
                if(nid){
                    $('.modal-date').html(arr_calendar[nid].field_event_date);
                    $('.modal-title').html(arr_calendar[nid].field_event_title);
                    $('.modal-thumbnail').html(arr_calendar[nid].field_event_image);
                    $('.modal-description').html(arr_calendar[nid].field_event_description);
                }
            });

calendar

I have also modified your js so that when clicking a date on the calendar, a pop up will appear with some description as shown below: capture

However when the calendar load for the first time, everything works fine. I mean for example: When clicking on the 02, my modal popup with content for the date 02. This is ok for all the date when clicked.

Now let’s assume I have clicked on the 10th and its content has been loaded in the modal. Now if I clicked on the prev or next button and when I click on a date, it loads the modal with the content of the 10th and not the content of the date I just clicked.

Can you help me with this?

pickmeup.min.zip

I am attaching the pickmeup.js.min file because i have made some slight modification to add ID's on the selected date.

nazar-pc commented 7 years ago

To be honest, I don't think you need to modify anything, which is why I wouldn't dig into your mods. You can achieve showing modal on click with regular event listener, demo: https://jsfiddle.net/y06mk8dr/