简体   繁体   English

CSS不适用于首次点击

[英]CSS is not applying on first click

I have two calendars implemented in one page, but in two different popup boxes. 我在一页中实现了两个日历,但是在两个不同的弹出框中。 These two calendars have two different CSS applied (eg 1.css, 2.css). 这两个日历应用了两种不同的CSS(例如1.css,2.css)。 I used jQuery to enable and disable a calendar in one of the popup boxes. 我使用jQuery在一个弹出框中启用和禁用日历。 Currently, I am getting new CSS applied when the calendar is open, and removed when the calendar is closed. 当前,当日历打开时我将应用新的CSS,而当日历关闭时将其删除。

My issue is, on first click, it is first applying the old CSS, and after I close the calendar and click it again, then it's applying the new CSS. 我的问题是,第一次单击时,首先要应用旧的CSS,然后关闭日历并再次单击它,然后再应用新的CSS。

Here is the code I used: 这是我使用的代码:

$('#inputField').datepicker({
 beforeShow: function(input, inst) {
        $('div#div1').append($('#ui-datepicker-div'));
        $('link[title=2-css]')[0].disabled=false;
    },
 onClose: function() {
        $('div#div2').append($('#ui-datepicker-div'));
        $('link[title=2-css]')[0].disabled=true;
    }
});

How can I fix this? 我怎样才能解决这个问题?

This issue has been resolved. 此问题已得到解决。 Like I mentioned in my question, I have two calendars on same page with different css. 就像我在问题中提到的那样,我在同一页面上有两个具有不同CSS的日历。 Since, the both calendar has same component, there was namespace conflict. 由于两个日历具有相同的组件,因此存在名称空间冲突。 The reason I append datepicker to an empty div was to isolate one calendar with another. 我将datepicker附加到一个空div的原因是为了隔离一个日历和另一个日历。 Aparently it did work but was not the 100% accurate. 显然它确实有效,但并非100%准确。 So, I changed the namespace of one calendar that is being used as class for css. 因此,我更改了一个用作css类的日历的名称空间。 This solved my problem. 这解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM