Home > Software engineering >  Show hide info.event.extendedProps.description Jquery
Show hide info.event.extendedProps.description Jquery

Time:11-28

I am trying to make info.event.extendedProps.description field show hide when I click event title in Fullcalendar list view. But it only works partly.

Example here

I added this under eventDidMount and works for line 1,3,5,7 etc. But not 2,4,6,8 etc `

     //Initially hide all the item-content
    $('.item-content').hide();

    // Attach a click event to item-title
    $('.item-title').on('click', function () {
        //Find the next element having class item-content
        $(this).next('.item-content').toggle();
    });

`

CodePudding user response:

Use off(), off() method removes event handlers that were attached with .on(), so its works.

In your case:

$('.item-title').off().on('click', function () {
    //Find the next element having class item-content
    $(this).next('.item-content').toggle();
});

Note: I tested your code with off() on your codepen and it's work.

CodePudding user response:

Cool thanks. I updated Codepen example.

I had many events in the list so I did not see it at first but it seems the last event in the list is not affected at all. Description is shown and no toggle.

Any idea why the code does not affect last event in the List view?

  • Related