[Solved] How can I add mysql abilities to tagmate? [closed]


The documentation on that tagmate library is crap. It says the sources option will accept a function, but it doesn’t tell you what args it receives. If you dig into the source it looks like it takes a term as the first arg and a function you should call as the 2nd. So you’ll want to fire off your ajax request in there and then call done(results) when it returns.

Consult jQuery to figure out how to perform your ajax request. You’ll want to pass along the supplied term to your PHP backend so that you can perform your SQL query.

Something like this:

$("#myTextarea").tagmate({
    sources: function(data, done) {
        $.ajax({
            url: '/api/users.php', // will receive $_GET['term']
            data: data
        }).done(function(result) {
            done(result); // should return JSON data in the format [{label:'Mr. Foo',value:'foo'}]
        });
    }
});

1

solved How can I add mysql abilities to tagmate? [closed]