Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Use ajax to autocomplete in tagit widget

$
0
0

am using tag-it plugin in jQuery and it works fine. But i can't set the autocomplete function.

Here is my script:

<script type="text/javascript">
        $(document).ready(function () {
            $('#tags').tagit({
                tagSource: function (request, response) {
                    $.ajax({
                        type: "POST",
                        url: "Main/TagHelper",
                        data: request,
                        dataType: 'json',
                        contentType: "application/json",
                        success: function (choices) {
                            showChoices(this._subtractArray(choices, this.assignedTags()));
                        }
                    })
                }
            });
        });</script>

...and code-behind method:

public ActionResult TagHelper(string term)
    {
        var data = db.Tags
            .Where(t => t.Name.StartsWith(term))
            .Select(t => t.Name)
            .Take(10);

        return Json(data, JsonRequestBehavior.AllowGet);
    }

I was finding where is the problem. But all i know is, that method $.ajax() is called. But i do not understand jQuery, so i do not know why it does not work.

 

 


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>