Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
codingarmadillo opened this issue May 26, 2016 · 1 comment
Open

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

codingarmadillo opened this issue May 26, 2016 · 1 comment

Comments

@codingarmadillo
Copy link

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
Copy link
Owner

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

  • Use extension method .Source() to specify source function name:
@Html.Bootstrap().TextBox("MyInput").TypeAhead(new TypeAhead().Action("MyAction").Source("mySource"))
  • add this function name to the scripts on the page:
<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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants