ExtJS 4选择元素的最佳方式 [英] ExtJS 4 Best way to select an element

查看:97
本文介绍了ExtJS 4选择元素的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在代码中(我使用MVC模型如果重要),要获取特定的元素,我使用参考。

In the code (I use MVC model if it matters), to get a specific elements, I use refs.

refs: [
    {
        ref: 'window',
        selector: 'windowName'
    },
    {
        ref: 'windowButton',
        selector: 'windowName button[name=buttonName]'
    },
    {
        ref: 'windowCombo',
        selector: 'windowName combo[name=comboName]'
    }
]

这是获取元素的正确选择吗?或者我必须使用getCmp()或其他东西?

Is this the right choice to get an elements? Or I have to use getCmp() or something else?

推荐答案

以下是一些在应用程序中定位组件的提示。 / p>

Here are some tips on targeting a component in an app.


  1. 首先要非常小心使用组件上的ID。我看到我们与他们共享的问题。避免一切代价。

其次,ExtJS提供了几种定位方式组件元素。不要混用两个。

Second, ExtJS provides several ways of targeting Components and Elements. Don't mix the two.

For Components:
    • Ext.getCmp(id)
    • Ext.ComponentQuery.query() 
    • up() 
    • down() 
    • nextSibling() 
    • previousSibling()
    • child()
    • previousNode()
plus various find.. Methods

For Elements:
    • Ext.get()
    • Ext.dom.Query() 

(更多关于DOM查询 http://docs.sencha.com/core/manual/content/domquery.html

(more on DOM Query http://docs.sencha.com/core/manual/content/domquery.html

这篇关于ExtJS 4选择元素的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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