I am trying to sort table based on column header using tablesorter jquery plugin(i.e jquery.tablesorter.js). I have web-resource for jquery.tablesorter.js in the plugin descriptor file and I am using webResourceManager.requireResource() with proper web resource key to import the resource in my velocity template. In my velocity template I am using $("#reportfields").tablesorter(); to sort tables where my table id is reportfields. still I am not getting srting functionality to this table.
I've tried it and it worked. See example below:
atlassian-plugin.xml
<web-resource key="example-resources" name="Web Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <resource type="download" name="jquery.tablesorter.min.js" location="/js/jquery.tablesorter.min.js"/> <context>example</context> </web-resource>
velocity page - example.vm
<html> <head> $webResourceManager.requireResource("com.exmaple.plugin:example-resources") <script type="text/javascript"> var $ = AJS.$; $(document).ready(function() { $("#myTable").tablesorter(); $("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} ); } ); </script> </head> <body> <div> <table id="myTable" class="tablesorter"> <thead> <tr> <th>Last Name</th> <th>First Name</th> <th>Email</th> <th>Due</th> <th>Web Site</th> </tr> </thead> <tbody> <tr> <td>Smith</td> <td>John</td> <td>jsmith@gmail.com</td> <td>$50.00</td> <td>http://www.jsmith.com</td> </tr> <tr> <td>Bach</td> <td>Frank</td> <td>fbach@yahoo.com</td> <td>$50.00</td> <td>http://www.frank.com</td> </tr> <tr> <td>Doe</td> <td>Jason</td> <td>jdoe@hotmail.com</td> <td>$100.00</td> <td>http://www.jdoe.com</td> </tr> <tr> <td>Conway</td> <td>Tim</td> <td>tconway@earthlink.net</td> <td>$50.00</td> <td>http://www.timconway.com</td> </tr> </tbody> </table> </div> </body> </html>
Note that you should not include another copy of jQuery in the file, but use the one from AUI.
Boris, Thanks for your reply. it worked.
But it created one more problem with context.
I am displaying JIRA deafult header toolbar by using follwing in my velocity template
<meta name='decorator' content='atl.general'/>.
But its not functioning properly whenever I use Jquery-tablesorter web resource in my velocity template.
so far I have not used ant conetxt in my Jquery-tablesorter web resource.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What about the second suggestion?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here're a couple of suggestions:
AJS.$("#reportfields").tablesorter()
or
$= AJS.$; $("#reportfields").tablesorter();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Boris,
I tried your suggestions, but still I am not able to sort my table. Following is my updated script.
<script type="text/javascript">
$(document).ready(function(){
AJS.$("#tp").html("This is Hello World by JQuery");
AJS.$("#reportfields").tablesorter();
});
</script>
My browser script console logs showing following errors:
Error: TypeError: F(...).on is not a function
Error: TypeError: jQuery.namespace is not a function
Error: TypeError: JIRA.Forms is undefined
Error: TypeError: jQuery.aop is undefined
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's AJS.$(document).ready
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Renjith,
AJS.$(document).ready doesnt work.
I used
<script type="text/javascript">
$(document).ready(function(){
AJS.$("#tp").html("This is Hello World by JQuery");
AJS.$("#reportfields").tablesorter();
});
</script> and it worked.
But whenever i replace $(document).ready(function() with AJS.$(document).ready, it doesnt work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.