Skip to content

Default (pre-selected) values using AJAX and templating #5392

@timroberson

Description

@timroberson

I am using an AJAX data source and a custom selection template. My custom selection template makes use of additional data returned by the remote data source (not just "id" and "text"). When I pre-select a value using the example from the documentation my additional data is "undefined".

The following example shows the issue using Select2 4.0.6-rc.0:

https://jsbin.com/deluyabija/edit?html,js,output

I expect the pre-selected option to be "My Other Option (More Custom Data)" but it is "My Other Option (undefined)".

I read #5210 and this message board post which deal with the same problem but neither includes a clear resolution. I feel like #5210 reads more like a support question rather than a bug report, so I am opening a new issue. I have not seen a statement that this is deliberately not supported, so I consider it a bug.

Please let me know if this is a bug or if what I'm looking to do is not supported by design. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions