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

I can't get the selected element to show in the input #398

Open
rafaxplayer opened this issue Aug 12, 2021 · 0 comments
Open

I can't get the selected element to show in the input #398

rafaxplayer opened this issue Aug 12, 2021 · 0 comments

Comments

@rafaxplayer
Copy link

rafaxplayer commented Aug 12, 2021

Hi, I'm new to this library and it's working great except that when I select an item it doesn't print it in the input.
This is my code:
Javascript:
`$('#Autocomplete').typeahead({
source: function(query, process){

            $.ajax({
                url:"./php/autocomplete.php",
                type:"POST",
                data:{query,query},
                dataType:"json",
                async: true,
                success:function(data){
                    process($.map(data, function(item){
                        return JSON.stringify(item);
                    }));
                }
            })   
        },
        items: 10,
        highlighter: function(tema) {
		    var item = JSON.parse(tema);		
            var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
            return item.name.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
                return '<strong>' + match + '</strong>'
            }) ;
	    }, 
        updater: function(tema) {
            var item = JSON.parse(tema); 
            //$('#Autocomplete').val(item.name);      
            $('#PadreSlug').val(item.slug);
	    }
    })`

Html

`


Tema principal (Original)
Nombre del tema padre

<input name="padre" id="Autocomplete" autocomplete="off" data-provide="typeahead" class="form-control" type="text" value="" required>

        </div>`
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

1 participant