Troubleshooting issue with Bootstrap collapse functionality failing with dynamic IDs

Having trouble creating dynamic ids for bootstrap collapsing functionality. I want each topic in an ng-repeat to collapse and display its respective question list when clicked.

The issue is that when I click on a second topic, the question list data from the first collapsed topic is displayed instead of the current one.

Here is the HTML code:

<div class="topic-div">
                    <p class="topic-heading">Topics</p>
                </div>
                <div class="arrow-down"></div>
                <ul>
                    <li ng-repeat="topics in oJdDetails.topics" class="topic-li"  ng-click="fngetQList(topics,$index)">
                        <p class="topics-p"> {{topics}}</p>
                        <ul uib-collapse="isCollapsed">
                            <li ng-repeat="value in aQuestionList">{{value.quesList.quesListName}}</li>
                        </ul>
                    </li>
                </ul>

JavaScript code:

$scope.fngetQList = function(topics, index) {
            debugger;
            $scope.isCollapsed = true;
            $scope.displayQList = true;
            $scope.sTopics = topics;
            $scope.index = index;
            getCandidateInterviewListService.fnGetQList(topics).then(function(response) {
                $scope.aQuestionList = response;
                console.log($scope.aQuestionList);
            });
        };

I'm struggling to figure out how to resolve this issue. Any assistance would be greatly appreciated.

Answer №2

If you're working with Angular, it's recommended to steer clear of using jQuery, especially when it comes to implementing Bootstrap. The team behind Angular has created a dedicated wrapper for Bootstrap that works seamlessly with the framework.

Instead of relying on jQuery, consider using this library from Angular UI: http://angular-ui.github.io/bootstrap/

By utilizing this library, you can forego the need for jQuery altogether. Check out how easy it is to implement features like collapsible elements without jQuery: http://angular-ui.github.io/bootstrap/#/collapse

This approach leverages Bootstrap's CSS file while integrating Angular-provided Javascript functionalities, eliminating the necessity for jQuery in your project.

With Angular being a robust Javascript library on its own, there's no need to add unnecessary bloat by incorporating jQuery as well.

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

Tips for managing state updates in React Redux

Currently, I am utilizing a reducer to manage the state in Redux. The current structure of my state is as follows: { activeConversation: "Jim" conversations: (7) [{…}, {…}, {…}, {…}, {…}, {…}, {…}] user: {id: 8, username: &quo ...

increase the selected date in an Angular datepicker by 10 days

I have a datepicker value in the following format: `Fri Mar 01 2021 00:00:00 GMT+0530 (India Standard Time)` My goal is to add 60 days to this date. After performing the addition, the updated value appears as: `Fri Apr 29 2021 00:00:00 GMT+0530 (India St ...

Is it common to encounter a "no such file or directory" error when running Docker-Compose with the command "ENTRYPOINT ['./init.sh']" in a Dockerfile?

Contemplate the docker-compose configuration : version: '3.0' volumes: data: driver: local networks: simple-network: driver: bridge services: postgres: container_name: postgres image: postgres ...

Monitoring and recording user's browsing activities while excluding server-side scripting

Currently, I am working on creating a registration form which will direct users to a "Thank you" page once completed. However, I want to include a button on this confirmation page that will take users back to the previous page they were on before registeri ...

Tips for moving a polygon while dragging a marker within its boundaries

Currently, I have a map displaying polygons and markers, accompanied by a sidebar featuring tool buttons (similar to the setup showcased in this demo: ). Each marker on my map is connected to the respective polygon stored in my database. When I utilize the ...

"Limitation observed - function operates only on first attempt

I have been working on a map project that involves pulling information from Google about various locations using the library available at https://github.com/peledies/google-places In order to troubleshoot and identify the issue with the code related to ma ...

Utilize ng-repeat to generate a dropdown menu from a list of objects

Here is a sample of how my object appears: var models = { "Test1":{ "name":"Test1", "members": { "T1":{//some more properties}, "T2":{//some more properties} ...

HTML elements generated dynamically do not possess any jQuery properties

I have implemented a draggable list of Div elements using jQuery. Here is the code: <div id="external-events"> <h4>List Of Staffs</h4> <div class="external-event" data-id="1">Name</div> //Draggab ...

Creating an HTML5 video tag with bearer authentication using a WebAPI: The ultimate guide

My ASP.NET WebAPI requires bearer authentication, and most of my requests towards the API follow this format: GET http://localhost:29080/api/v1/users/me HTTP/1.1 Host: localhost:29080 Connection: keep-alive Accept: application/json, text/plain, */* Origin ...

Utilizing Server-Sent Events to display a interactive navigation button

Currently, I am managing a web-based point of sale system where some buttons are hidden for specific functions. To streamline the process, I would like to allow managers to simply click on an "Enable" button in the admin panel and have it immediately refle ...

Merging Technology: Integrating Maps into Hybrid Applications

Currently, I am developing a mobile application using React-Native with a main focus on: Map Integration: Partial Success - I have successfully implemented all features mentioned in this link. The remaining task is to display live routing based on curren ...

Ways to deactivate selecting rows in a datatable

Is there a way to deactivate the select feature specifically within datatables? An example of using ctrl+a for disabling select all function is available here https://i.stack.imgur.com/RQNXT.png ...

Unable to locate module '.next/server/font-manifest.json'

I'm encountering a frustrating issue while attempting to deploy my nextjs app with server rendering. The app was created using Azure Pipelines and then uploaded to a production server that runs on a Linux operating system. Below is the configuration ...

Controller receiving empty object array from FormData

I am encountering an issue with my ajax call to the controller, where I am passing FormData() containing an array of objects and other properties. The list array that I pass seems to have 0 elements in the controller. Can anyone assist me with this problem ...

The fonts in node.js are not functioning as expected, without displaying any error messages

I'm having trouble implementing custom fonts on my website. Despite following the correct file structure, the fonts do not seem to be loading. My project files are organized in the following manner: https://gyazo.com/5ee766f030290e5b2fa42320cc39f10b ...

"Enhance your website with dynamic uploader forms and AJAX scripts - Railscast #383 shows you

I've successfully implemented the uploader functionality from Railscast #383, but I'm wondering if it's possible to dynamically add and remove the uploader link using ajax? Additionally, I'd need to include the "service" instance id wh ...

What is the best way to send a reply from a GET request query on the server side of an express application?

Currently, I am utilizing a query to interact with a Postgres database in order to save the result into a variable within a GET request on the server-side of an Express application. Although my query successfully returns the desired issueID when executed ...

Injection of Angular state resolve into controller fails to occur

I'm attempting to ensure that the value from ui-router's resolve is successfully passed to the controller portalsForUserCtrl. Take a look at the router code below: (function () { 'use strict'; var myApp = angular.module("myApp", ["co ...

Is there a way to automatically remove flash messages in AngularJS after a certain period

For controlling the timing of clearing my FlashService message, I attempted to implement a timeout feature. However, it seems to function more like a delay. FlashService.Success(("Removed Successfully"), false); In this instance, I have used false as a c ...

An introduction to the basics of AngularJS, AJAX, and ASP.NET MVC

I am struggling with creating a simple AngularJS example that makes an AJAX call to an ASP.NET MVC action method. I have tried various approaches but haven't been successful yet. Below is the code snippet I have been working on... The ASP.NET MVC act ...