DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
221 stars 78 forks source link

Is it possible to pass an ID to TypeAhead controller? #423

Open codingarmadillo opened 8 years ago

codingarmadillo commented 8 years ago

I'd like to pass an configurable ID to my TypeAhead controller, e.g.

public ActionResult Index(long id, string term)

Is that possible?

DmitryEfimenko commented 8 years ago

Yes, please get latest as I've updated javascript file in order to handle this.

@Html.Bootstrap().TextBox("MyInput").TypeAhead(new TypeAhead().Action("MyAction").Source("mySource"))
<script type="text/javascript">
    function mySource(term, process) {
        var url = $('#MyInput').data('url');
        var id = 1; // whatever the custom logic for that parameter

        return $.getJSON(url, { id: id, term: term }, function (data) {
            return process(data);
        });
    }
</script>