Paul-DS / bootstrap-year-calendar

[DEPRECATED] A fully customizable year calendar widget, for boostrap !
Apache License 2.0
294 stars 243 forks source link

how to use "customDayRenderer" #134

Closed Linbubin closed 7 years ago

Linbubin commented 7 years ago

who can give me a full html about "customDayRenderer".

I don't understand how to use it. anyway, thanks :)

I want to make "dataSource" looks like disabled day(but dataSource still can display location and update or delete event). I use setTimeout(function(){$('td[style^="box-shadow"]').addClass('disabled').css('box-shadow','')},100);. but when i change year, it Invalid. so i want to know how to make dataSource look like "disabled" forever。

William-H-M commented 7 years ago

Hi, you can do it like this

customDayRenderer: function(element, date) {
       $(element).addClass('disabled');
 //where element it's each day and you still can see the events
        }
Linbubin commented 7 years ago

@William-H-M sorry, I don't know where add this code. Can you help me revise this,and push it?

Or help me find a full page。 anyway , thanks!

William-H-M commented 7 years ago

Hi, after some try I saw that if using the way I told you it won't work as is not applying to the container so the logic will actually be:

customDayRenderer: function(element, date) {
       $(element).parent().addClass('disabled');
        }

But thios will cause some bug that doesn't show the events as is need it, so I just solved in the easy way just add this in the buttom of your script

  $( document ).ready(function() {
    setTimeout(function(){ $(".day").addClass('disabled'); }, 0);
    });

This will make what you want.

BTW: For what exactly you want this? if you just don't want to create events you can just remove the part of createEvent

Linbubin commented 7 years ago

@William-H-M I want to use all the events in [full example]() include(create, update, delete).

but i don't know how to show the DataSource looks like disable (after all events, switch year, and loaded).

so I add

setTimeout(function(){$('td[style^="box-shadow"]').addClass('disabled').css('box-shadow','')},100);

every events function.

but when I switch to another year, it won't work.

if I use your code:

  $( document ).ready(function() {
    setTimeout(function(){ $(".day").addClass('disabled'); }, 0);
    });

it make all page looks like "disabled", but I want to make "DataSource" looks like "disabled",(for example, remove underline and add class="disabled") and I want this effect still works when I switch the year.

Do I need to make myself clear?

Can you help me add some JS to achieve this effect?

the html effect is this

code

Linbubin commented 7 years ago

@William-H-M
hi, I found a way, but it looked a little stupid,just add

yearChanged: function(e){
           setTimeout(function(){$('td[style^="box-shadow"]').addClass('disabled').css('box-shadow','')},100);
           }

when I switch year, it work well!