2011-09-23 6 views
1

내 응용 프로그램 홈페이지에서 '위젯'시스템을 구축했습니다. 위젯의 소스는 서버 측에서 생성되며 Ajax를 통해 클라이언트로 푸시됩니다.은 Ajax 요청에서 인라인 스크립트를 실행합니다.

Ext.Ajax.request({ 
    url: '/get-widgets', 
    success: function(response) { 
     var boxes = Ext.decode(response.responseText); 
     Ext.each(boxes, function(box) { 
      box.id = 'cell-' + box.cell; 

      var element = Ext.DomHelper.append('canvas', { 
       tag: 'div', 
       id: box.id, 
       cls: 'widget size-' + (box.size || '11'), 
       children: [{ 
        tag: 'div', 
        cls: 'title', 
        html: box.title 
       }, { 
        tag: 'div', 
        cls: 'main', 
        html: box.body 
       }] 
      }, true); 
     }); 
    } 
}); 

일부 위젯에는 본문에 인라인 Javascript가있어서 실행해야하는 것이 문제입니다. 이것은 Firefox에서 완벽하게 작동하지만 Chrome에서는 작동하지 않습니다.

인라인 코드를 실행하려면 활성화해야 할 플래그 또는 무언가가 있습니까?

답변

1

발견 된 Ext.Element::update() 메서드는 인라인 스크립트를 검색하고 실행할 플래그가 있습니다. 이 방법을 사용하기 위해 다음과 같이 코드를 변경했습니다.

var element = Ext.DomHelper.append('canvas', { 
    tag: 'div', 
    id: box.id, 
    cls: 'widget size-' + (box.size || '11') + ' ' + (box.cls || '') + ' ' + (box.type || ''), 
    children: [{ 
     tag: 'div', 
     cls: 'title', 
     html: box.title 
    }, { 
     id: box.id + '-body', 
     tag: 'div', 
     cls: 'main' 
    }] 
}, true); 

Ext.get(box.id + '-body').update(box.body, true); 
관련 문제