Bugfixing the user picker tutorial? auiSelect2 usage Edited

I'm trying to reuse some code from https://bitbucket.org/atlassian_tutorial/connect-select2-user-picker - a plugin tutorial from 2013. 

I'm able to make a simplistic sample work like on the auiSelect2 documantation, but when I run the code from Step 4 of the tutorial there's an error with this segment (key line is at "data: function"):

$userPicker.auiSelect2({
        hasAvatar: true, // auiSelect2 speciffic option, adds styling needed to properly display avatars
        multiple: true, // make the control a multi-select
        ajax: {
            url: "/rest/api/2/user/picker", // JIRA-relative URL to the REST end-point
            type: "GET",
            dataType: 'json',
            cache: true,
            // query parameters for the remote ajax call
            data: function data(term) {
                return {
                    query: term,
                    maxResults: 1000,
                    showAvatar: true
                };
            },

 Error message:

 

Encountered \"data\" at /templates/assign/editAssign.vm[line 43, column 36]\nWas expecting one of:\n    \",\" ...\n    \"}\" ...\n    \"}\"

This suggests the ajax part is malformed, but I'm not sure why or how to fix it. Is this indicative of another problem?

I've already had to remove //comments to prevent error.

 

1 answer

1 accepted

Accepted Answer
0 votes

Self-solved: was using .vm files, or Apache Velocity. While this works fine with $.whatever variables like in other samples I used, it does not work with $whatever variables - like $userPicker. The line quoted in the error is a red herring.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published 8 hours ago in Jira Ops

Jira Ops Early Access Program Update #2: Let’s talk severity levels

Welcome to your weekly Jira Ops Early access program update, where we’re sharing news and updates on Jira Ops' progress as we work toward our 1.0 release. If you ever want to drop us feedback or idea...

20 views 0 0
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