$.ui.autocomplete not working in User Macro

Shubham Garg June 26, 2016

I am unable to use 

var results =$.ui.autocomplete.filter(collection, extractLast(request.term));

this in a macro

Whereas the same works when inserted inside an html macro on the page.

 

Error occurred rendering macro is given.

2 answers

1 accepted

1 vote
Answer accepted
Stephen Deutsch
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.
June 27, 2016

Inside a user macro, the $ symbol is interpreted as the start of a variable, so jQuery code often throws an error.  You can either assign a variable to the $ symbol and use it where you would normally use it (like this: ${j}.ui), or simply use "jQuery", which is what I usually do.

So in a user macro, it should look like this:

var results = jQuery.ui.autocomplete.filter(collection, extractLast(request.term));
0 votes
Steve Gerstner [bridgingIT]
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.
June 26, 2016

jQuery is usually wrapped in AJS, so try

var results =AJS.$.ui.autocomplete.filter(collection, extractLast(request.term));

Shubham Garg
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 26, 2016

Tried it.

But It does not work. Gives the same error

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events