$.ui.autocomplete not working in User Macro

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
Stephen Deutsch Community Champion Jun 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));

jQuery is usually wrapped in AJS, so try

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

Tried it.

But It does not work. Gives the same error

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,916 views 27 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you