开发者

How to prevent checkAll selection for future dates?

We have a list of days at the top of the table header and we want to disable the Check All capability if the selected day is greater than the current day (e.g. today is 30th, but the select 31st). We will allow checkAll to work for any date less than the current date. How do we achieve this?

    <script type="text/javascript">
        jQuery(document).ready(function(){
            // This provides selectAll, clearAll capability
            jQuery('#records').find('thead th').click( function(){
                var ch = jQuery(this).find("input[type='checkbox']").attr('checked');
                var col = jQuery(this).prevAll().length;
                var ch = jQuery(this).find("input[type='checkbox']").attr('checked');
                jQue开发者_高级运维ry('#records').find('tbody td').each( function(){
                    var tdId = jQuery(this).attr('id');
                    if(col == tdId) {
                        if(jQuery(this).hasClass('user-present')) {
                            // Toggle the value of attribute checked for the checkbox
                            jQuery(this).find("input[type='checkbox']").attr('checked', true);
                        }
                    }
                });
            });

        });
    </script>


1) You can mark every 'future' date with a CSS class on the server-side and then just write a proper CSS selector to filter them;

2) You can append a title attribute with a date string (e.g. 2010-07-30) to every element and further compare two dates.

var today = new Date();
var check_me = new Date("2012-12-21"); // element.attr("title") instead of "2012-12-21" in your case
if (check_me <= today)
{
    //Everything is ok
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜