$.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
Accepted answer
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
Community showcase
Published 9 hours ago in Confluence Cloud

Happy holidays from our team to yours!

Hi Community!  2018 was filled with changes for our team, both big and small, and we've taken a lot of time to both celebrate our wins and recognize areas of improvement. One thing that we're a...

86 views 0 11
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