AJS.sidebar is not a function

I’m new in this.
I want to use sidebar, to control it’s expand and collapse,like this


In my code:var sidebar = AJS.sidebar(’.aui-sidebar’);
But i get this wrong
Uncaught TypeError: AJS.sidebar is not a function

Hi @11190 ,
It is probably that the JS resource for sidebar :

  • is not loaded into the page
  • or is loaded but after your code had been executed

So, please make sure you are loading web resource with key com.atlassian.auiplugin:aui-sidebar as a dependency of your code.

Best regards,
Nam Ho

1 Like

Thx your reply.
The dependency in atlassian-plugin.xml
image
But it doesn’t work.
When i write this in vm


It works…

Hi @11190,
Can you post your atlassian-plugin.xml?

You should add aui-sidebar dep to web-resource or context.
Example with web-resource:

<atlassian-plugin key="your.plugin.key" name="name-of-the-plugin" >
   ....
    <web-resource key="your-resource">
        <dependency>com.atlassian.auiplugin:aui-sidebar</dependency>

        <resource type="download" name="plugin.js" location="js/plugin.js" />
    </web-resource>
</atlassian-plugin>

Then load your web-resource in code:

$webResourceManager.requireResource("your.plugin.key:your-resource");

Best regards,
Marcin Konopka

2 Likes