开发者

jQuery Tools - disable weekend days

i'm looking for solution, how to disable weekend days (sat, sun) in jQuery Tools Datepicker. I know there is solution for jQueryUI, but 开发者_如何学Pythoni need it for this, because the project is almost 99% complete, so digging into code for something else isn't good idea at this time.

http://flowplayer.org/tools/dateinput/index.html


you could add something like this :

$(".date").dateinput({
    change: function() {
        var dayOfWeek = this.getValue('ddd');
                if( dayOfWeek === 'Sat' || dayOfWeek === 'Sun'){
                    this.hide();
                    return false;
                }
    }
});

Further enhancements:

  • you could pop up an alert box to warn the user they cant choose weekends
  • you could style the css to make weekends look disabled


I have also come across this problem and I have come up with the following solution:

var dateinput = $('input[type="date"]').dateinput({
    "onShow": function(event) {
        var calendar = this.getCalendar();
        var conf = this.getConf();
        var classes = conf.css.off + ' ' + conf.css.disabled;
        function disableWeekends() {
            var weeks = calendar.find('.calweek');
            weeks.find('a:first, a:last').addClass(classes);
        }
        calendar.find('#calprev, #calnext').click(disableWeekends);
        disableWeekends();
    }
});

https://gist.github.com/1031709

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜