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

This widget could not be displayed.
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));
This widget could not be displayed.

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
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

464 views 6 6
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