PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 24, 2022

[FIXED] Block individual date in pickadate.js

 January 24, 2022     javascript, laravel-5, php, pickadate     No comments   

Issue

When I tried to block an array of individual dates, it's not blocking but when I try using some date range I am able to block the dates.

Below mentioned code is working as I am passing:

blocked_dates.push({ from: [2020, 4-1, 17], to: [2020, 5-1, 17], inverted: true });
@foreach($available_dates_arr as $adate)
   available_dates.push({from:new Date({{ date("Y", strtotime($adate['start'])) }}, {{ date("n", strtotime($adate['start'])) }}-1, {{ date("j", strtotime($adate['start'])) }}), to:new Date({{ date("Y", strtotime($adate['end'])) }}, {{ date("n", strtotime($adate['end'])) }}-1, {{ date("j", strtotime($adate['end'])) }})});
@endforeach

blocked_dates.push({ from: [2020, 4-1, 17], to: [2020, 5-1, 17], inverted: true });
var $input = $('.datepicker').pickadate({
        disable: available_dates,
        min: min_date,
        selectMonths: true,
        selectYears: true,
        format: 'dd-mmm-yy'
    });
    picker = $input.pickadate('picker');

    if (blocked_dates && blocked_dates.length) {  
        picker.set('enable', blocked_dates);
    } 

But when I pass blocked_dates.push([2020, 4-1, 17, 'inverted']); its not blocking the dates.

Ref : pickadate.js

Thanks in advance :)


Solution

After trying a lot i came up with idea and did the same way, what i did for any date range.

So if i have to block any individual date, then i am passing the same date to both from and to.

blocked_dates.push({ from: [2020, 4-1, 17], to: [2020, 4-1, 17], inverted: true });
blocked_dates.push({ from: [2020, 5-1, 20], to: [2020, 5-1, 20], inverted: true });

I know its not the way to block individual date what they mentioned in documents but it works for me.



Answered By - Prafful Panwar
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing