Reyes RK
Reyes RK

Reputation: 1

Use FullCalendar eventClick info in SweetAlert2 JSP condition

I'm using FullCalendar API for a calendar page in my website that's supposed to track a maintenance schedule of equipment. I also used SweetAlert2 as the popup modal for when an eventClick happens.

eventClick: function(info) {   
                var eventTitleParts = info.event.title.split('for');
                var eventCat = eventTitleParts.length > 1 ? eventTitleParts[1].trim() : '';
                console.log(eventCat);
                    Swal.fire({
                    title: info.event.title,
                    icon: 'info',
                    showConfirmButton: true,
                    html: `
                        <table style="width: 100%; text-align: left; border-collapse: collapse;">
                            <tr>
                                <td style="font-weight: bold; padding: 8px; border-bottom: 1px solid #ddd;">Date:</td>
                                <td style="padding: 8px; border-bottom: 1px solid #ddd;">`+info.event.start.toLocaleDateString()+`</td>
                            </tr>
                            <tr>
                                <td style="font-weight: bold; padding: 8px; border-bottom: 1px solid #ddd;">Location/s:</td>
                                <td style="padding: 8px; border-bottom: 1px solid #ddd;">
                                    <c:set var="eCat" value="` + eventCat + `"/>
                                    <c:set var="eCat2" value="Aeration Blower"/>
                                    <c:set var="eCat3" value="${eventCat}"/>
                                    <div>${eCat} test</div>
                                    <div>${eCat2} test2</div>
                                    <div>${eCat3} test3</div>
                                    <div>${eventCat} test4</div>
                                 </td>
                            </tr>
                        </table>
                    `,
                    confirmButtonText: 'Close'
                  });
                }

Assuming info.event.title is Annual Maintenance for Chiller, the outputs should be as follow:

Chiller test
Aeration Blower test2
Chiller test3
Chiller test4

However, the output is currently like this:

Chiller test
Aeration Blower test2
 test3
 test4

I want to be able to use eCat, or just eventCat in general as a condition for a c:forEach loop I want to implement later. For now, I'm just trying to get them to properly be put in jsp variables. I've tried using sessions, mixed up concatenations just like in eCat, and reordering the code but it doesn't display no matter what.

Upvotes: -1

Views: 48

Answers (0)

Related Questions