0

in my app ,i want to create some function like extjs4 api,when i click the left tree menu, the content will show in the right.some code list below: left tree menu code:

var tree_panel = Ext.create('Ext.tree.Panel', {
            listeners: {
    'itemclick': function( grid, record, item, index, e, eOpts) {
        Ext.Ajax.request({
             url: 'code/list.js',
             success: function(response){
                show_tip_message("success!")
             },
             failure: function(response){
                  show_tip_message("false!")
             }
         });
      }
    }

codecontroller code(codecontroller.rb)

   def list
   respond_to do |format|
    format.js 
   end
end

codeview code(list.js.erb)

  var m_work_space = Ext.getCmp('work-space');
    m_work_space.removeAll();
    m_work_space.add(m_codegrid);
    m_work_space.doLayout();

however when i click the tree item, it pop out notice success ,but the work-space doesn't refresh ,why? any help will appreciate

4

1 回答 1

0

也许您应该在成功回调中添加更新代码?

listeners: {
    itemclick: function( grid, record, item, index, e, eOpts) {
        Ext.Ajax.request({
            url: 'code/list.js',
            success: function(response){
                var m_work_space = Ext.getCmp('work-space'),
                    m_codegrid = response.responseText;

                m_work_space.removeAll();
                m_work_space.add(m_codegrid);
                m_work_space.doLayout();

                show_tip_message("success!")
            },
            failure: function(response){
                show_tip_message("false!")
            }
        });
    }
}
于 2013-05-30T18:27:47.060 回答