JavaScript pass Algolia id attribute instead of Name Atributre in a post request on Laravel 5.2

Using the Javascript, Vue.js and Typeahead.js way shown by Jeffery Way and Algolia docs to index json objects from the Algolia platform.

Currently when i search for the result i require and hit the submit button, It is passing the name attribute through in the post request.

How is it possible to pass the name and the id attribute or if nescessery just the ID arrtibute would work.

<script>
new Vue({
    el: 'body', 
    data: {     
    query: '',
    users: []       
    },  
ready: function(){
this.client = algoliasearch("MYID", "MYAPI");
this.index = this.client.initIndex('dev_category_list');
$('#typeahead').typeahead(null, {   
    source: this.index.ttAdapter(),
    displayKey: 'name'
});
},
  methods: {
    search: function(){
        if (this.query.length < 3) return;
    this.index.search(this.query, function(error, results){
    this.users = results.hits;
    }.bind(this));
    }     
}  
})
</script>

As a total newcomer the laravel, vuejs and javascript its somewhat difficult to get to grips with the syntax and phrases used when explaining the instructons within the docs so any help would be greatly appreciated.

My indexed objects look like so:

{
  "id": "3",
  "name": "My Product 3",
  "value": "3",
  "alternative_name": "Prod 3",
  "objectID": "3"
}

Im hoping to pass the value of ID or objectID along with the name attribute in a post request once the user selects the given result from the algolia drop down menu and hits the submit, just the ID would work as mentioned above if its not possible.

Thanks.


--- Update referencing Jerska: ---

Ok so after playing around as a newbie for a little bit i seem to have it working, Im not exactly sure how secure this is or how reliable one would say, Hopefully im not a million miles off from where i need to be. Be good to see what your personal and professional thoughts are.

.on('typeahead:select', function (e, suggestion) {
   $('#typeahead').change(function() {
    var val = suggestion.id;
    $('#st').val(val);
});

I have created a hidden input field and named is 'st' for a demo and on update of the algolia results jquery is using the .change function to append the value to the hidden input fields value. That way the form can be continued and sibmitted as i originally wanted and hoped for, The benefit here is that even if the user is to select a result from algoia drop down menu then continue with the form, If he or she decides they want to go back to the search field and change it, They can do before they submit the form or before any window.location is run, I even thought of using ajax or simply jquery $.post but its working ok the .change

Look forward to hearing your thoughts. Thanks

Answer:1

I’m pretty new to backbonejs and i’m trying to create a basic application. The application is something like this: I have 5 sections: A, B, C, D and E Each section has 2 radio buttons. Section A - ...

I’m pretty new to backbonejs and i’m trying to create a basic application. The application is something like this: I have 5 sections: A, B, C, D and E Each section has 2 radio buttons. Section A - ...

Simply, i'm trying to use jQuery to append a numeric value (currently stored in an array) to the end of the "id" attribute of a number of specified elements. $('#headerAfirstLink, #headerAsecondLink, ...

Simply, i'm trying to use jQuery to append a numeric value (currently stored in an array) to the end of the "id" attribute of a number of specified elements. $('#headerAfirstLink, #headerAsecondLink, ...

  1. append array value in php
  2. append array value in javascript
  3. append array value in jquery
  4. append array value python
  5. append array value
  6. append array value js
  7. append array values swift
  8. append array values numpy
  9. append value array bash
  10. adding array value in php
  11. append values array java
  12. adding array values in javascript
  13. adding array values in java
  14. adding array values
  15. adding array values python
  16. adding array values in c#
  17. append array key value php
  18. c append array value
  19. python append array values to list
  20. vba array append value

I'm using the jQuery .append() function to input content into HTML elements via their id like so; function returnGameDetailed(data) { $('#game-synopsis').append(data.results.deck); } For ...

I'm using the jQuery .append() function to input content into HTML elements via their id like so; function returnGameDetailed(data) { $('#game-synopsis').append(data.results.deck); } For ...

  1. jquery append multiple divs
  2. jquery append multiple lines
  3. jquery append multiple items
  4. jquery append multiple html elements
  5. jquery append multiple times
  6. jquery append multiple options to select
  7. jquery append multiple input
  8. jquery append multiple lines of html
  9. jquery append multiple
  10. jquery append multiple td to tr
  11. jquery append multiple attributes
  12. jquery append multiple rows to table
  13. jquery append multiple li to ul
  14. jquery append multiple objects
  15. jquery append multiple classes
  16. jquery append multiple variables
  17. jquery append multiple nodes
  18. jquery append multiple options
  19. jquery append multiple copies
  20. jquery append multiple attr

Issue happens when I upload multiple files. Let's say I upload 7 files, some times it only takes 2 - other times all 7 files. I am not expecting any return yet, just using dropzone and move the file ...

Issue happens when I upload multiple files. Let's say I upload 7 files, some times it only takes 2 - other times all 7 files. I am not expecting any return yet, just using dropzone and move the file ...

  1. dropzone upload multiple files
  2. dropzone upload multiple false
  3. dropzone upload multiple files at once
  4. dropzone upload multiple not working
  5. dropzone upload multiple
  6. dropzone upload multiple example
  7. dropzone upload multiple files php
  8. dropzone upload multiple true
  9. dropzone multiple upload php
  10. dropzone.js upload multiple files
  11. react dropzone upload multiple files
  12. dropzone.js upload multiple
  13. dropzone disable multiple upload
  14. dropzone js multiple file upload php
  15. dropzone js multiple file upload example