0

I don't know why , but when I try to set the $scope variables Inside the autocomplete , nothing happens , well the $scope variables got undefined,($scope.shipperdescripcion and $scope.shipperlocation) but I need to know how to make it work , thx

$(".shipper").autocomplete({
      minLength: 3,
      source: "controllers/search.php?catalogo=plantas",      
      select: function(event, ui, $scope){       
         $(this).val(ui.item.value).change();
         $scope.shipperdescripcion = ui.item.id;
         $scope.shipperlocation = ui.item.desc;
         return false;
      },
      change: function (event, ui, $scope) {
         if (ui.item == null) {
            $scope.shipperdescripcion = '';
            $scope.shipperlocation = '';
         }
      }
   })
   .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
      return $( "<li>" )
      .data( "item.autocomplete", item)      
      .append( "<a><b>" + item.value + "</b><br>" + item.desc + "</a>" )      
      .appendTo( ul );
   };
3
  • Look into building a directive for this... stackoverflow.com/questions/12959516/… Commented Apr 17, 2014 at 15:49
  • I'm using this directive now with angular but I don't know how use the _renderItem , I download it , it's called autocomplete.js Commented Apr 17, 2014 at 16:14
  • Try $scope.$apply(). Commented Apr 17, 2014 at 20:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.