"Resolving Compatibility Issues Between Bootstrap 4 and fullcalendar.js: Embedding Fullcalendar Within a Bootstrap 4 Modal

I am currently using fullcalendar.js in conjunction with Bootstrap 4 modal.

Whenever I click on a bootstrap4 button, a modal appears with the fullcalendar component displayed.

However, upon initial load, I encounter this issue:

https://i.sstatic.net/nniKI.png

Strangely enough, clicking on the next/prev buttons resolves the problem

https://i.sstatic.net/I8eIe.png

So, my question is how can I resolve this?

HTML code:

<body>

        <div id="content">

            <button id="btn-calendar" type="button" class="btn btn-dark" data-toggle="modal" data-target="#modal-calendar"><i class="fas fa-calendar-alt"></i></button>

            <div class="modal fade" id="modal-calendar" tabindex="-1" role="dialog" aria-labelledby="modal-calendar-title" aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="modal-calendar-title">Calendar</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <div id="calendar"></div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            <button type="button" class="btn btn-primary">Save changes</button>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <!-- script tags -->
</body>

CSS code:

* {
  margin: 0;
  padding: 0;
}

html,
body,
#content {
  width: 100%;
  height: 100%;
}

#btn-calendar {
  margin: 10px;
}

Answer №1

Creating the object after opening the modal for the first time seems to be the key to making it work.

//app.js

$(function() {
    var render = () => {
        console.log('render after modal is open');   
        $('#calendar').fullCalendar({
            // setup
        })
        $('.modal').unbind('shown.bs.modal', render)
    }
    $('.modal').on('shown.bs.modal', render)
})

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process for extracting dates in JavaScript?

I need help extracting the proper date value from a long date string. Here is the initial date: Sun Aug 30 2020 00:00:00 GMT+0200 (Central European Summer Time) How can I parse this date to: 2020-08-30? Additionally, I have another scenario: Tue Aug 25 ...

Ways to modify the CSS of an active class within a child component when clicking on another shared component in angular

In my HTML template, I am encountering an issue with two common components. When I click on the app-header link, its active class is applied. However, when I proceed to click on the side navbar's link, its active class also gets applied. I want to en ...

Tips for modifying the icon of a div with a click event using vanilla JavaScript

My goal is to create a functionality where clicking on a title will reveal content and change the icon next to the title. The concept is to have a plus sign initially, and upon clicking, the content becomes visible and the icon changes to a minus sign. C ...

Is there a way to add additional text to a text element within an SVG?

Is it possible to append a new text element at the end of the data label by clicking on that particular text? I have attempted to implement this in my code but the additional text is not being displayed as expected: circleGroup.selectAll("text") ...

Update the div content to completely replace it with fresh data using Ajax

I'm currently working on implementing a currency switcher feature for my website, allowing users to toggle between two different currencies. The site is a reservation platform with a booking form displayed on the left side and the booking details occu ...

block the UI when a certain amount of time has passed

When I click on a button, I implement the following code: $(document).ready(function () { $('.find').click(function () { $.blockUI({ message: '<table><tr><td><img src="images/pleas ...

Bootstrap - Keeping track of the collapse state of <div> elements after page refresh

Looking for some guidance as a javascript/jquery beginner - I am utilizing Bootstrap along with data-toggle and collapse classes to display or hide divs. I have been searching online trying to find a solution that will maintain the state of all divs, wheth ...

What is the most effective approach - should we use nested functions or is there a better

Do both of my examples have the same functionality, considering that I'm handling errors by terminating with res.json(400, err)? Also, I want to confirm that in my second example, the second async.each always runs after the first one, so is it safe to ...

How to use jquery and ajax to retrieve an array of data and show it on the screen

I am facing an issue with my ajax request. Actually, I am unsure of how to fetch multiple records. I attempted the following: $rqt = "SELECT a,b,c from table"; $res = mysql_query($rqt); while ($data = mysql_fetch_assoc($res)): $objet = $d ...

Passing Optional Parameters to AngularJS Modal

Is there a way to pass an optional parameter to my angularJS modal? Let's take a look at the code: TRIGGER CONTROLLER: $modal.open({ templateUrl: 'UploadPartial.html', controller: 'photos.uploadCtrl', resolve: { presele ...

Issue encountered while parsing JSON file using AngularJS

Having some trouble reading a json file in AngularJS using $http.get and encountering errors in the browser console. Check out my Plunker example: http://plnkr.co/edit/SDRpu1MmrTPpgpdb6Kyk?p=preview Below is the code snippet: Javascript:- var jayApp = ...

Incorrect positioning of dropdown menu when using Bootstrap 4 and translate3d() function

Having multiple bootstrap 4.4.1 dropdown menus, each within a column which is functioning correctly except for the position calculation. Example of HTML col: <div class="container"> <div class="row"> <div class="col"> <div ...

Tips on preventing a header and body text from wrapping around a floated image positioned in the upper left corner

If we consider the layout order like this: H3 <LEFT-FLOATED IMG> <text> <H3> <LEFT-FLOATED IMG> <text> For smaller screen sizes, everything looks fine: https://i.sstatic.net/Dz0BB.png But when the screen gets bigger, a prob ...

Utilizing jQuery to pinpoint the exact position within a Flexbox container

I have a unique setup with multiple boxes arranged using Flexbox as the container and list tags as individual boxes inside. These boxes are responsive and change position as the width is resized. My goal is to use jQuery to detect which boxes are touching ...

I am having trouble with the browser detection not accurately identifying the browser I am currently using

Currently, I am working on a JavaScript code that will simply display the name of the browser being used to view the web page. Despite me using Safari, none of the navigators seem to recognize it as the current browser. The information displayed in my brow ...

Regular expression: Strip the brackets from a portion of the text

I have a JavaScript application where I need to manipulate strings. The text follows this structure: It might begin with a prefix in square brackets [prefix]. I have to preserve this prefix with the brackets. Next comes [whatever string], in this case I ...

Error in Spring when updating with PATCH API in React JS due to missing request body

Spring exhibition - Error Resolved: Required request body is missing for updating delivery status Console error - Error: Request failed with status code 400 class UpdateOrder extends Component { state = { deliveryStatus:"" } handleCha ...

Creating a cohesive In-Line Navbar Form with Bootstrap 4

Currently, I have designed a navigation bar using Bootstrap 4. My aim is to incorporate the search bar in line with the navigation bar. I have applied the 'form-inline' class to the search form, however, the search button still appears below the ...

User-Preferred Dark Mode Toggle Using Material-UI and Fallback Option

I am working on implementing a toggle for "dark mode" that is functioning well. However, I want the initial state to reflect the user's dark/light preference. The problem is that prefersDarkMode seems to be set to false when the page loads. It only c ...

The selected attribute does not function properly with the <option> tag in Angular

Currently, I am faced with a challenge involving dropdowns and select2. My task is to edit a product, which includes selecting a category that corresponds to the product. However, when I open the modal, the selected group/category is not displayed in the d ...