如何添加数据 - 属性ExtJS的呈现的HTML? [英] How to add data- attributes to ExtJs rendered html?

查看:266
本文介绍了如何添加数据 - 属性ExtJS的呈现的HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ExtJS的4.1。

Using ExtJs 4.1.

我创建一个面板(例如),我想这生成的HTML包括一个或多​​个数据 - 属性(例如:数据介绍=一些文本数据 - 步=1

I'm creating a panel (for example) and I would like that the generated html includes one or more "data-" attributes (for example: data-intro="some text" data-step="1")

如何才能做到这一点?

推荐答案

在组件已呈现后,你可以申请的属性重新presenting组件

After the component has rendered, you could apply the attributes to the top level element representing the component

例如:

var panel = Ext.create('Ext.panel.Panel',{
    title: 'Test',
    width: 500,
    height: 200,
    renderTo: Ext.getBody(),
    listeners: {
        afterrender: function(cmp) {
            cmp.getEl().set({
                "data-intro": 'some text',
                "data-step": 1
            });
        }
    }
});

panel.show();

这篇关于如何添加数据 - 属性ExtJS的呈现的HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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