Skip to content

How to pass source in callback? #2

@mattcheah

Description

@mattcheah

Hi, Thanks for creating this widget - it's really useful.

I've been trying to use multisearch with ajax to get the source list of searchable items from a database, but I cannot figure out how to create pass that list back to the source. This is my code:

$("#item-search").multisearch({
  source: function (term, callback) {
    $.ajax({
            type: 'POST',
            url: url,
            data: {term:term},
        })
        .done(function(data) {
            //console.log(data) -> ["item1","item2", "item3", "etc"]
            callback(data); //similar to how you do it in line 180 here: bseth99.github.io/jquery-ui-multisearch/examples/movies.html
        })
  });

Currently the picker shows 5 "undefined"s regardless of how many results are returned.
Let me know if there's something I'm missing. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions