nazar-pc / PickMeUp

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

show/hide calendar input #147

Closed MadanBhandari closed 7 years ago

MadanBhandari commented 7 years ago

Hi, I am trying to show/hide calendar input. I mean If user click on input without selecting date, calendar should be hide if shown or vice-versa.

pickmeup('input.check-in-date', {
      position       : 'top',
      class_name         : 'dt1',
      default_date   :  false,
      prev           : '<i class="fa fa-angle-left"></i>',
      next           : '<i class="fa fa-angle-right"></i>',
      hide_on_select : true,
      render : function (date) {
        if (date < now) {
          return {disabled : true, class_name : 'date-in-past'};
        }
        return {};
      }
    });
nazar-pc commented 7 years ago

Sorry, but I do not quite understand what do you need. Can you describe it step by step or elaborate somehow in more details?

MadanBhandari commented 7 years ago

Sorry for late, I am trying to close/hide calendar on click input field without selecting date. As like hide_on_select for hiding after selection but I want to hide without selecting date.

nazar-pc commented 7 years ago

Did you try hide method for this?

MadanBhandari commented 7 years ago

Yeah, but how can I trigger this event hide(), that element is already bind on click event.

nazar-pc commented 7 years ago

Still can't quite understand what you need. hide method is separate from click event, it can be used directly. Can you describe step by step what are you doing (or want to do), then what happens and what did you expect to happen instead. Or even better, prepare some demo on jsfiddle or jsbin to describe the question.

MadanBhandari commented 7 years ago

I want to do is toggle show/hide on click (input - without selecting date).

nazar-pc commented 7 years ago

Then you can subscribe to click event, suppress original even handler, and show/hide as you like. Here is demo: https://jsfiddle.net/e70LyyL4/

MadanBhandari commented 7 years ago

This is exactly what I needed but It's not working on Chrome (v 52.0.xx), and working on Firefox.

On Chrome "pmu-hidden" class gets removed ONLY when window is resized.

There is no warning or error on chrome but Firefox gives Warning :

Use of getPreventDefault() is deprecated. Use defaultPrevented instead.

nazar-pc commented 7 years ago

This one should work in all browsers: https://jsfiddle.net/e70LyyL4/1/

nazar-pc commented 7 years ago

Also I don't think getPreventDefault() comes from PickMeUp

MadanBhandari commented 7 years ago

same issue on fiddle you shared, check that on Chrome (v 52.0.xx) too. I have checked on different system too, same problem with Chrome and Safari.

nazar-pc commented 7 years ago

Works fine for me in Chromium Nightly 55.0.2880.0. Anyway, you get the idea.

MadanBhandari commented 7 years ago

No, I didn't get what's the problem, I am beginner in JS. I am facing same problem in Chromium 52.0.2743.116 (Developer Build) Built on Ubuntu

nazar-pc commented 7 years ago

Well, I gave you the code which works for me. If it doesn't work for you, I can't fix it, since:

MadanBhandari commented 7 years ago

Thanks for your advise and time, I will look into this.