如何从extJS点击事件中访问其他extJS对象? [英] How can I access other extJS objects from within extJS click events?

查看:159
本文介绍了如何从extJS点击事件中访问其他extJS对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 menuItem1 对象的点击事件的以下代码中,如何更改 renderContent 对象,所以当用户点击菜单项的标题时,页面中间的内容会更改?

In the below code in the click event for my menuItem1 object, how can I change the html content of the renderContent object so when the user clicks the menu item's header, the content in the middle of the page changes?

(在我看的所有例子中,点击事件正在创建新对象,但不会更改现有对象。)

(In all the examples I look at, the click events are creating new objects but not changing existing objects.)

Ext.onReady(function(){

    var menuItem1 = new Ext.Panel({
        id: 'panelStart',
        title: 'Start',
        html: 'This is the start menu item.',
        cls:'menuItem'
    });

    var menuItem2 = new Ext.Panel({
        id: 'panelApplication',
        title: 'Application',
        html: 'this is the application page',
        cls:'menuItem'
    });

    var regionMenu = new Ext.Panel({
        region:'west',
        split:true,
        width: 210,
        layout:'accordion',
        layoutConfig:{
            animate:true
        },
        items: [ menuItem1, menuItem2 ]
    });

    var regionContent = new Ext.Panel({
        region: 'center',
        padding:'10',
        autoScroll: true,
        html: 'this is the content'
    });

    new Ext.Viewport({
        layout: 'border',
        items: [ regionMenu, regionContent ]
    });

    menuItem1.header.on('click', function() {
        alert('this appears in alert window');
    // regionContent.set('html', 'new text'); //nothing appears, no error
    // regionContent.set('html', 'new text'); //nothing appears, no error
    // Ext.get('regionContent').html = 'new text'; //error: "regionContent is null"
    // Ext.getCmp('contentArea').html = 'the new text'; //nothing appears, no error
    // Ext.getCmp('contentArea').set('html', 'new text'); //error: "set is not a function"


    });

});


推荐答案

尝试使用update方法:

Try using the "update" method:

regionContent.update('new text');

这篇关于如何从extJS点击事件中访问其他extJS对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆