I'm trying to load a dijit calendar on click of dijit icon button with specific dates disabled,
for this I tried two ways
first one:
loading calendar in js function
getting error as trying to register "id==mycal"
but that id is already registered ."
<button data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:oncldriconclick" data-dojo-props="iconClass:' dijitIconTable', showLabel: false" type="button"></button>
<div id="mycal" data-dojo-attach-event="onclick: _onDayClick" ></div>
oncldriconclick : function() {
disable_before_days = 2;
var calendar = new Calendar({
value: new Date(),
isDisabledDate:function(date, localString){
return dojoDate.difference(date, new Date(), "day") > disable_before_days
|| locale.isWeekend(date)
|| date > new Date() ;
}
}, "mycal");
},
onDayClick:function(evt){
alert(evt);
},
Second method: loading calendar in postcreate of js function with var calendar = registry.byId("mycal");
if I load with below html and passing isdisableDate
arguemnts in postcreate
function , the disable dates are not applying on startup but they are applying only after the selection of some date I need this to be applied on startup of calendar
<button data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:oncldriconclick" data-dojo-props="iconClass:' dijitIconTable', showLabel: false" type="button"></button>
<div id="mycal" class="mycal" data-dojo-attach-point="mycal" data-dojo-type="dijit.Calendar" data-dojo-attach-event="onChange: _onDayClick" ></div>
postCreate: function(){
disable_before_days = 2;
var calendar = registry.byId("mycal");
console.log(locale );
calendar.isDisabledDate = function(date, localString){
return dojoDate.difference(date, new Date(), "day") > disable_before_days || locale.isWeekend(date) || date > new Date() ;
}
},
how can I get disabled dates on calendar startup with these any one of the methods.
the error is because you are creating a widget ( new ) with id mycal that was already instantiated ( defined in dojo registry ) ,
all you need is put the instantiation in postCreate and in the button just toggle display using the
"dojo/dom-style"
class :then your button will have only show or hide calendar ,
add also css to hide calendar on startup