【问题标题】:Referencing the HTML objects inside a Sencha Touch Container在 Sencha Touch Container 中引用 HTML 对象
【发布时间】:2012-10-21 05:38:56
【问题描述】:

我正在使用 Sencha Touch 2.0.1。我正在尝试获取对容器中某些 HTML 的引用。 (我的目标是读取对象的宽度,并在必要时缩小字体大小以使其适合)。

这是我的代码:

Ext.define("SFCT.view.Flashcard", { 
    extend: 'Ext.Container', 

    xtype: 'flashcardpanel', 


    requires: [ 
        'Ext.TitleBar' 
    ], 

    config: { 
        itemId: 'mainScreen', 
        title: 'Flashcards', 

        layout: 'fit', 

        items: [ 
            { 
                xtype: 'container', 
                layout: { 
                    type: 'vbox', 
                    pack: 'center' 
                }, 
                items: [ 
                    { 
                        xtype: 'container', 
                        itemId: 'wordContainer' 
                    } 
                ], 
                style: 'text-align: center' 
            }, 
            { 
                xtype: 'button', 
                docked: 'right', 
                text: 'Next', 
                action: 'next' 
            } 
        ] 
    }, 

    updateWord: function(newWord) { 
        var s = '<div style="font-size: 72px">' + newWord+ '</div>'; 
        var c = Ext.ComponentQuery.query('#wordContainer')[0]; 
        console.log(c.getHtml()); 
        c.setHtml(s); 
    } 
}); 

如果我使用如上所示的 Ext.Container.getHtml(),它会将 HTML 作为字符串返回。但我正在寻找对 div 元素本身的引用,以便获得它的宽度。

有什么想法可以做到吗?

谢谢。

【问题讨论】:

  • 您能否详细说明您的问题? wordContainer 中的 html 代码在哪里?
  • 克里斯托夫在下面回答了它;我试图获取对 HTML 元素本身的引用。

标签: sencha-touch sencha-touch-2


【解决方案1】:

如果我没记错的话

c.element

应该给你一个被包装元素的引用。

【讨论】:

  • 还有 Ext.DomQuery.select('#wordContainer');我认为。
猜你喜欢
  • 1970-01-01
  • 2023-03-11
  • 1970-01-01
  • 2011-09-12
  • 2013-02-15
  • 1970-01-01
  • 1970-01-01
  • 2014-02-06
  • 1970-01-01
相关资源
最近更新 更多