Where can I change javascript code and CSS code in my webpart files?

Roma Patel 0 Reputation points
2023-08-12T20:42:17.1866667+00:00

Hello,

I'm building an accordion webpart using this link: https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/add-jqueryui-accordion-to-web-part#build-the-accordion 

I've completed all the steps and the accordion that shows up with the code provided works great. However, I'm trying to change up the code to make a nested accordion using the code from this site: https://codepen.io/Elodieb/pen/OJyLxXm 

I don't understand which file or section I should put in the necessary Javascript code. I updated the HTML in the MyWebpartTemplate.ts file and I assume the CSS code goes in the Webpart.module.scss file which are both under src\webparts\

Please help I've been stuck on this for hours and it's my first time doing front-end coding. The code editor im using is VSC

Microsoft 365 and Office Development Office JavaScript API
Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2023-08-14T02:53:37.17+00:00

    Hi @Roma Patel,

    We can render the list item using REST API using this.context.spHttpClient.get() method in the public render():void method in .ts file.

    The following articles for your reference.

    Retrieve SharePoint List Items Using SharePoint Framework Development Model

    How to add external libraries and assets in SharePoint client-side web part

    Use existing JavaScript libraries in SharePoint Framework client-side web parts


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.