Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

AJS.$ equivalent for the ".each" function

CharlesH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2013

I've been updating some of my older user macros which called jQuery directly AJS.$ as recommended here: https://confluence.atlassian.com/display/CONFKB/How+to+Use+JavaScript+in+Confluence

Some of my code uses the .each function of jQuery.

If I replace "jQuery.each() {...}" with "AJS.$.each() {...}" then a Velocity Parser Exception error is thrown and the macro doesn't work.

If I try "AJS.each() {...}" then there's no sign of an error, but the macro doesn't work.

I've checked this forum and the documentation (https://developer.atlassian.com/display/AUI/AJS+helper+functions) but found no examples of how the .each function can be used from AJS.$.

Anyone come across this before and found a solution?

Thanks,

Charles

1 answer

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2013
CharlesH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2013

Those examples both use AJS.$.each which I've tried, resulting in an error.

I'm running Confluence 4.2.1, so perhaps the AJS library offers support for .each in more recent versions?

I notice other users have been having similar trouble. In this case with the .ajax method - https://answers.atlassian.com/questions/131487/ajax-calls-breaking-confluence

Neither .ajax nor .each work for me. I get a similar error to the one posted in that topic.

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2013

can you share the error message ?

CharlesH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2013

The error message recorded in the Confluence log file is as follows:

Caused by: org.apache.velocity.exception.ParseErrorException: Encountered "," at getRenderedContent[line 86, column 30]
Was expecting one of:
    <EOF> 
    "(" ...
    <RPAREN> ...
    <ESCAPE_DIRECTIVE> ...
    <SET_DIRECTIVE> ...
    "##" ...
    "\\\\" ...
    "\\" ...
    <TEXT> ...
    "*#" ...
    "*#" ...
    <STRING_LITERAL> ...
    <IF_DIRECTIVE> ...
    <STOP_DIRECTIVE> ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <WORD> ...
    <BRACKETED_WORD> ...
    <IDENTIFIER> ...
    <DOT> ...
    "{" ...
    "}" ...

The line number & position given relates to this line in the user macro:

Old version - works fine:

86 jQuery.each(rows, function(index, row) {
87 row.sortKey = sortKey(AJS.$(row).children('td').eq(column));
88 });


New version - errors:

86 AJS.$.each(rows, function(index, row) {
87 row.sortKey = sortKey(AJS.$(row).children('td').eq(column));
88 });

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events