Is it possible to load a webresource with javascript? I'm wanting to load the sortable table (com.atlassian.auiplugin:aui-experimental-table-sortable) web resource but can't do it in an atlassian-plugin.xml as I'm not creating a plugin. I'm adding the table to the page after load via ajax.
Community moderators have prevented the ability to post new answers.
Davin, I'm not sure if you can load it with Javascript in an efficient manner, but you could include it at load time with a user macro:
#requireResource("com.atlassian.auiplugin:aui-experimental-table-sortable")
After the table is loaded, you can make it sortable (source):
AJS.tablessortable.setTableSortable(AJS.$("#delayedSortedTable"));
Yeah, I was considering the user macro approach as a last resort, but if it can be done via JS I woudl rather go that route.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm ... just to give it a shot I tried this, and I still don't see the AJS.tablessortable.setTableSortable() method. The JS console says that setTableSortable is undefined. This is my user macro. It is included on the Confluence page. My Key parameter in the page is set to com.atlassian.auiplugin:aui-experimental-table-sortable. It looks to me like this should work. Is the documentation correct? By the way I'm on 5.3.4.
## Developed by: Davin Studer
## Date created: 12/30/2013
## @paramKey:title=Resource Key|type=string|required=true|desc=Resource key.
#requireResource($paramKey)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Haha. I'm glad you got it working :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok. I'm a goober. I accidentally had a " at the end of the user macro param ... yeah that won't work. Works fine now that I put in the correct key.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, so it seems that this IS possible to do this entirely with Javascript, but again -- it's not very efficient.
AJS.loadWebResourceTemplates("com.atlassian.auiplugin:aui-experimental-table-sortable", "aui-experimental-tables-sortable.css"); AJS.loadWebResourceTemplates("com.atlassian.auiplugin:aui-experimental-table-sortable", "jquery.tablesorter.js"); AJS.loadWebResourceTemplates("com.atlassian.auiplugin:aui-experimental-table-sortable", "aui-experimental-tables-sortable.js");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did see that method earlier, but when I tried running that in the console I still didn't get the AJS.tablessortable.setTableSortable method. Guess I'll just resort to Velocity ... oh well! Thanks for the help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have the same problem. Can't load the proper webresource.
After reading this post i still don't undrestand how you fixed it.
What is that -> #requireResource
I only know it like this
${webResourceManager.requireResourcesForContext("my-plugin")}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is a shorthand way to call the requireResourcesForContext method via velocity.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.