2011-03-29 5 views
0

jqgrid가 서버에서 그리드에 데이터를 입력 한 후에 함수를 실행하려고합니다. 호출되는 함수는 다음 jqgrid 요청을 위해 csrf 토큰을 전역 var로 업데이트합니다.jqgrid OnComplete 함수가 작동하지 않습니다.

$("#customer_grid").jqGrid({ 
    mtype: 'POST', 
    url:'jqgrid/customer', 
    postData: { <?php echo $csrf_token_name; ?>: csrf_token }, 
    datatype: 'json', 
    colNames:['Account #', 'Firstname', 'Surname','Postcode','Address 1','Address 2', 'Address 3', 'City', 'County', 
       'Country', 'Email', 'Home Tel', 'Mobile Tel', 'Work Tel'], 
    colModel :[ 
     {name:'id', index:'id', width:80}, 
     {name:'firstname', index:'firstname', width:80}, 
     {name:'surname', index:'surname', width:80}, 
     {name:'postcode', index:'postcode', width:80}, 
     {name:'address_1', index:'address_1', width:80}, 
     {name:'address_2', index:'address_2', width:80}, 
     {name:'address_3', index:'address_3', width:80}, 
     {name:'city', index:'city', width:80}, 
     {name:'county', index:'county', width:80}, 
     {name:'country', index:'country', width:65}, 
     {name:'email', index:'email', width:80}, 
     {name:'home_tel', index:'home_tel', width:80}, 
     {name:'mobile_tel', index:'mobile_tel', width:80}, 
     {name:'work_tel', index:'work_tel', width:80}, 
    ], 
    emptyRecords: "No Accounts Found", 
    pager: '#customer_grid_pager', 
    rowNum:10, 
    rowList:[5,10,25,50,100], 
    rownumbers: true, 
    sortname: 'id', 
    sortorder: 'desc', 
    viewrecords: true, 
    gridview : true, 
    caption: 'Customer Search', 
    height: '220', 
    autowidth: true, 
    onComplete: function(data, response) { 
      get_csrf_token(); 
      alert(csrf_token); 
    }, 
    ondblClickRow: function(id, row, column){    
      //alert('Hello World '+ id + ' ' + row + ' ' + column); 
      customer_id = id; 
      //alert(customer_id); 
      crud_action = 'update'; 
      $('#new_customer').show(); 
      $('#customer_search').hide(); 
      customer_crud('read'); 
      show('#details'); 
    } 



    }); 

방화 광은 자바 스크립트 오류를 ​​표시하지 않으며 get_csrf_token()은 호출되지 않습니다. 내가 볼 수없는

감사

+0

get_csrf_token() 함수를 게시 할 수 있습니까? – glomad

+0

@ithcy get_csrf_token()은 GET을 사용하여 서버에서 토큰을 검색합니다. – JohnCook

+0

해당 함수에 구문 오류가있는 경우 jqGrid 코드가 평가되지 않을 수 있기 때문에 묻습니다. 하지만 그게 문제라고 생각하지 않습니다. 내 대답을 보라. – glomad

답변

1

onCompletejqGrid event로 나열. gridComplete 또는 loadComplete을 사용 하시겠습니까?

1

gridComplete: function(data, response) { get_csrf_token(); alert(csrf_token); },

관련 문제