简体   繁体   English

如何使用extjs4.2创建单个运行文本?

[英]How to create a single running text using extjs4.2?

How to create running text like a marquee non standard HTML element in Extjs4.2 ? 如何在Extjs4.2中创建运行中的文本,如字幕非标准HTML元素?

This is my snippet code that I've done so far : 到目前为止,这是我的片段代码:

 Ext.Loader.setConfig({ enabled: true, paths: { Ext: '.' } }); Ext.require([ 'Ext.form.*', 'Ext.XTemplate']); Ext.onReady(function () { //Ext.Msg.alert('Fiddle', Ext.get('info').dom.innerHTML); Ext.define('v_label', { extend: 'Ext.form.Label', xtype: 'runningText', renderTo: Ext.getBody(), constructor: function (config) { var me = this; var lbl = Ext.get('info').dom.innerHTML; this.data = { title: 'Title Sample', item: 'Item Sample' }; this.tpl = lbl; // contentEl: 'info', this.height = 40; Ext.apply(me, config); me.callParent(); } }); Ext.create('v_label'); }); 
 <script src="http://dev.sencha.com/deploy/ext-4.0.2a/ext-all-debug.js"></script> <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-4.1.1-gpl/resources/css/ext-all-debug.css" /> <div id="info"> <marquee scrollamount='4' onmouseout="this.setAttribute('scrollamount', 4, 0);" onmouseover="this.setAttribute('scrollamount', 0, 0);"><font size='5' color='red'><strong>{title} : {item}</strong></font> </marquee> </div> 

I define it so I can create a dynamic label and store the data dynamically from data:{} . 我定义了它,所以我可以创建一个动态标签并从data:{}动态存储数据。

You can see a running text, but it's double as you see. 您可以看到一个正在运行的文本,但它是您看到的文本的两倍。 I've try to store the marquee tag into tpl but i get stuck because the single quotes , the double quotes and the javascript to change the attribute marquee . 我已经尝试将marquee标记存储到tpl但由于single quotesdouble quotesjavascript to change the attribute marqueejavascript to change the attribute marquee卡住了。

My question is : How to make it a single running text ? 我的问题是:如何使其成为单个运行文本?

Or, 要么,

Maybe any another way to create running text in extjs4.2 ? 也许还有其他方法可以在extjs4.2中创建运行文本?

Based on your code, change the lbl as the following. 根据您的代码,将lbl更改为以下内容。

// use backslash
var lbl = '<div id=\'info\'><marquee scrollamount=\'4\' onmouseout=\"this.setAttribute(\'scrollamount\', 4, 0);\" onmouseover=\"this.setAttribute(\'scrollamount\', 0, 0);\"><font size=\'5\' color=\'red\'><strong>{title} : {item}</strong></font></marquee></div>';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM