jQuery-Autovervollständigung in der Klasse, wie man id

Habe ich schon eine Weile und kann nicht scheinen, um überall zu bekommen. Im Grunde habe ich die Autovervollständigung in einer Reihe von Eingaben, die durch die Klasse, aber ich brauche, um die bestimmten Eingaben-id-erstellen Sie das Objekt, um post-ajax (ich POST für dieses Projekt nicht BEKOMMEN).

$(".input_autocomplete").autocomplete({
  source: function( request, response ) {
  //here is where I get the hash from local storage,
  //reference the id and build the object
  //tried this.id, $(this).prop('id'), no luck
  $.ajax({
    url: '/somepath/filename.htm',
    contentType: 'application/json',
    dataType: 'json',
    type: 'POST',
    data: JSON.stringify(obj),
    success: function(json) {
      return {
        label: item.label,
        value: item.label
      }
    },
    error: function() {
      //error handling
    }
   }); //ajax
 } //source
});
  • Ich bin ganz neu bei jQuery aber, haben Sie versucht, mit attr('id') statt .prop('id')? Soweit ich weiß, die id ' s sind attr, nicht stützen... Auch, da bist du mit dot-syntax $(this) sollte der Weg zu gehen, da Ausrichtung auf das jQuery-Objekt. Hoffe, es löst das problem.
InformationsquelleAutor user1572796 | 2012-10-13
Schreibe einen Kommentar