admin管理员组文章数量:1278820
This should be simple, but I'm stupid so...
I want to do a simple conditional statement to see if the calendar has already been rendered within a div. Something like this:
if ( $('#calendar').fullCalendar() )
{
alert("calendar exists!!");
}
I want to do this so that I can remove, then re-init the calendar programatically. Basically, a 'reset' button.
Can someone please let me know the proper syntax to check if a fullCalendar object has been rendered?
Thank you in advance!!
This should be simple, but I'm stupid so...
I want to do a simple conditional statement to see if the calendar has already been rendered within a div. Something like this:
if ( $('#calendar').fullCalendar() )
{
alert("calendar exists!!");
}
I want to do this so that I can remove, then re-init the calendar programatically. Basically, a 'reset' button.
Can someone please let me know the proper syntax to check if a fullCalendar object has been rendered?
Thank you in advance!!
Share Improve this question edited Jul 14, 2010 at 18:22 MVO asked Jul 14, 2010 at 18:10 MVOMVO 1611 silver badge5 bronze badges3 Answers
Reset to default 8I figured it out. jQuery has a .children()
selector. I was able to do a conditional statement on the .length
property of that selector to see if there was any content in the div:
if ( $('#calendar').children().length > 0 ) {
alert("calendar exists!!");
}
An alternative way to do this, without jQuery, is:
getElementById('calendar').hasChildNodes()
This is kind of a hack, but each day cell has a class with the format fc-day-##
. The last cell has the number 41 (check it out in firebug). You could try to select td.fc-da-41
and if you get any elements then the calendar is fully loaded.
if ($('td.fc-day-41').size() > 0) {
//calendar ready
}
Maybe set it to check every couple hundred milliseconds with .setTimeout()
var checkCal = function() {
if ($('td.fc-day-41').size() > 0) {
//calendar ready
} else {
window.setTimeout(checkCal(), 200);
}
}
You can check something like easily
if($('#calendar>*').length !== 0) alert("calendar exists!!");
本文标签: javascriptProgrammatically check to see if calendar has been renderedStack Overflow
版权声明:本文标题:javascript - Programmatically check to see if calendar has been rendered - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741302140a2371148.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论