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

customize source #59

Open
dothanhit87 opened this issue Jun 13, 2017 · 1 comment
Open

customize source #59

dothanhit87 opened this issue Jun 13, 2017 · 1 comment

Comments

@dothanhit87
Copy link

How to customize bindata to soucre from ajax

@WG-Com
Copy link

WG-Com commented Dec 1, 2017

@dothanhit87

    horsey(document.querySelector('.suggest'), {
        source (data, done) {
            $.ajax({
                url : '',
                type:'post',
                dataType:'json',
                data:{
                   
                    search:data.input
                },
                success:function(items){
                    done(null, [{
                        list: items.filter(function (item) {
                            if(item.indexOf(data.input)!== -1) {
                                return true;
                            }
                            return false;
                        })
                    }])
                }.bind(this)

            });
        },
        getText:'name',
        getValue:'id',
        predictNextSearch(info) {
            //console.log(info.selection); return selected item data 
            $("input").val(info.selection.id)
        },
        limit: 20
    });

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