Expand my Community achievements bar.

SOLVED

Add desired child component in core accordion component

Avatar

Level 2

Has anyone done the following and if so how to do it?

I am overlaying the core accordion component. In 'items' tab, on the click of add , i want my desired child component to be dynamically added, i.e., i do not want to choose the child component from the dropdown but i want the slide to be added on click of add instead of going to dropdown to select the component.


Zendark_0-1732517902546.png

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Zendark ,


You can try below-

  1. Create a Sling Model - The model can manage the slides and includes a method to add a new slide to the JCR.
  2. Script to trigger slide addition:

$('.add-slide-btn').on('click', function() {

    $.ajax({

        url: '/bin/add-slide', // Custom Sling Servlet or endpoint

        type: 'POST',

        success: function() {

            // Reload or dynamically update the Accordion

        }

    });

});

  1. Create a Sling Servlet to call the addSlide() method in the Sling Model and save the slide to the JCR.

This solution allows for dynamic slide addition via a button, with the data being saved for persistence.

Thanks

Ritesh Mittal

View solution in original post

2 Replies

Avatar

Community Advisor

Hi @Zendark 
Its a multifield, so you can remove popup/selection logic and just add Title maybe.

And In your sling model read those number of items and , inject the Slider component in HTL.



Arun Patidar

Avatar

Correct answer by
Community Advisor

Hi @Zendark ,


You can try below-

  1. Create a Sling Model - The model can manage the slides and includes a method to add a new slide to the JCR.
  2. Script to trigger slide addition:

$('.add-slide-btn').on('click', function() {

    $.ajax({

        url: '/bin/add-slide', // Custom Sling Servlet or endpoint

        type: 'POST',

        success: function() {

            // Reload or dynamically update the Accordion

        }

    });

});

  1. Create a Sling Servlet to call the addSlide() method in the Sling Model and save the slide to the JCR.

This solution allows for dynamic slide addition via a button, with the data being saved for persistence.

Thanks

Ritesh Mittal