samedi 4 octobre 2014

Component without visual

Hi there,

I would like to create a class with all the pros an Ext.Component gives me.

But I do not need a visual appearance.


So I thought I could use AbstractComponent, but it gives me the error of a missing itemId.



Code:



Ext.define('App.view.components.AndroidAudio', {
extend: 'Ext.AbstractComponent',
xtype: 'myaudio',


config: {
/**
* @cfg {string} url
*/
url: null,
/**
* @cgf {number} volume
*/
volume: null,


/**
* @cgf {object} media object
*
* @private
*/
media: null
},


cachedConfig: {
baseUrl: 'resources/mp3/'
},


initialize: function () {
this.callParent(arguments);


App.messageBus.on('playertoggle', this.toggleRunning, this);
},


toggleRunning: function (state) {
var media = this.getMedia();


switch(state){
case 'play':
media.play();
break;
case 'close':
this.setUrl(null);
break;
default:
media.pause();
}
}
});

Because its not working for me that way I am currently using Ext.Component with hidden:true.

Is there a better way?

I also tried to add



Code:



constructor: function(config) {this.initConfig(config)}





Component without visual

Aucun commentaire:

Enregistrer un commentaire