문제

Does anyone know how to cause modelbinder's converter to wait until a ajax request is complete? I'm trying to use backbone's modelbinder on my view but the converter is failing because it is not waiting for the ajax call to complete before rendering

var convertIdToName = function(direction, value) {
   if(direction == 'ModelToView') { 
      $.ajax({url: 'rest/lookup?' + value}).done(data) { 
        return data[0].Name; }
   }
}

var binding = {Id: { selector: '[name=Id]', converter: convertIdToName }};
도움이 되었습니까?

해결책

I fixed this by seting

  async: false 

on ajax request

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top