$.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
Answer accepted

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
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

292 views 2 12
Read article

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