2014-07-08 3 views
2

ajax로 내 CKeditor 대화 상자 선택 상자를 채우려고합니다. 다음 내 plugin.js 파일에서입니다 :Ajax로 CKeditor 채우기 대화 상자를 선택하십시오.

... 
{ 
    type : 'select', 
    id : 'style', 
    label : 'Style', 
    setup : CKEDITOR.ajax.post( '.../ckeditor/plugins/simpleLink/ajax.php', JSON.stringify({ foo: 'bar' }), 'application/json', function(data) { 
      console.log(data); 
    }), 
    items : [ ['--- Select something ---', 0] ], 
    commit : function(data) 
    { 
     data.style = this.getValue(); 
    } 
} 
... 

아약스 출력은 다음과 같습니다

["Basketball","basketball"],["Baseball","baseball"],["Hockey","hockey"] 

내가 정말 "항목"으로 출력을 얻을하는 방법을 궁금해하고있다. 내 견해에서 나는 모든 것을 시도했다. 누군가 나를 도울 수 있습니까?

답변

1

해결 방법을 찾았습니다.

plugin.js : 이전

이 코드 "CKEDITOR.plugins.add ('PLUGINNAME', {..."

- 같은 문제가 누군가를 위해 여기를 해결하는 길이다
jQuery.extend({ 
getValues: function(url) { 
    var result = null; 
    $.ajax({ 
     url: url, 
     type: 'get', 
     dataType: 'json', 
     async: false, 
     success: function(data) { 
      result = data; 
     } 
    }); 
    return result; 
} 
}); 
var results = $.getValues('.../ckeditor/plugins/PLUGINNAME/ajax.php'); 

이 은 선택 상자

{ 
    type : 'select', 
    id : 'style', 
    label : 'Style', 
    setup : '', 
    items : results, 
    commit : function(data) 
    { 
     data.style = this.getValue(); 
    } 
} 
코드입니다
관련 문제