Sencha touch Ext.仅列出方向更改时的渲染
外部列表和外部面板代码Sencha touch Ext.仅列出方向更改时的渲染,sencha-touch,extjs,Sencha Touch,Extjs,外部列表和外部面板代码 Ext.namespace('Envato.AudioJungle.Previewer'); var lastItemClicked = null; // Stores the last 'play' or 'pause' item clicked on Envato.AudioJungle.Previewer.audioPreview = new Ext.Audio({}); // Blank audio player used to preview the items
Ext.namespace('Envato.AudioJungle.Previewer');
var lastItemClicked = null; // Stores the last 'play' or 'pause' item clicked on
Envato.AudioJungle.Previewer.audioPreview = new Ext.Audio({}); // Blank audio player used to preview the items
Envato.AudioJungle.Previewer.popularItemList = new Ext.List({ // The list of popular items
store: 'popularItemStore',
emptyText: 'No popular items found',
loadingText: 'Loading Items',
itemTpl: new Ext.XTemplate( // How we format the items when they come back
'<div class = "audio_jungle_item">',
'<img src = "{thumbnail}" class = \"thumbnail\">',
'<span class = "item_title">{[fm.ellipsis(values.item, 20, false)]}</span>',
'<span class = "item_author"> by {user} ({sales} sales)</span>',
'<div class = "x-button play_pause_button">Play</div>',
'</div>'
),
listeners: {
itemtap: function(self, index, item, e) {
var selectedItem = self.getRecord(item);
var tapTarget = e.getTarget(); // Stores what we clicked on
if(tapTarget.innerHTML == 'Play') { // We clicked on a 'Play button'
if(lastItemClicked && lastItemClicked.innerHTML == 'Pause') { // Another item is currently playing
lastItemClicked.innerHTML = 'Play'; // Switch the button to 'Play'
}
lastItemClicked = tapTarget; // Store the currently clicked item as the last clicked item
lastItemClicked.innerHTML = 'Pause'; // Set the button we clicked on to 'Pause'
if(Envato.AudioJungle.Previewer.audioPreview.url) { // Check to see that the audio previewer is not empty
Envato.AudioJungle.Previewer.audioPreview.pause(); // Pause it
}
// Reset the audio previewer to play the item clicked
Envato.AudioJungle.Previewer.audioPreview = new Ext.Audio({
id: 'audioPreview',
hidden: true,
url: selectedItem.get('preview_url'),
renderTo: Ext.getBody()
});
// Play the audio
Envato.AudioJungle.Previewer.audioPreview.play();
} else if (tapTarget.innerHTML == 'Pause') { // We clicked a pause button
Envato.AudioJungle.Previewer.audioPreview.pause(); // Pause playback
tapTarget.innerHTML = 'Play'; // Set the button to say 'Play'
} else {
Ext.Msg.confirm("Audio Jungle", "View this item at AudioJungle.com?", function(btn) {
if(btn == 'yes') {
location.href = selectedItem.get('url');
}
});
}
}
}
});
Envato.AudioJungle.Previewer.optionToolbar = {
dock: 'top',
xtype: 'toolbar',
title: 'AudioJungle - Popular Items'
};
Envato.AudioJungle.Previewer.displayPanel = new Ext.Panel({
layout: 'fit',
fullscreen: true,
dockedItems: Envato.AudioJungle.Previewer.optionToolbar,
items: Envato.AudioJungle.Previewer.popularItemList
});
Main.js代码
Ext.namespace('Envato', 'Envato.AudioJungle', 'Envato.AudioJungle.Previewer', 'Envato.Stores');
Ext.setup({
onReady: function() {
Envato.AudioJungle.Previewer.displayPanel.render(Ext.getBody()).doComponentLayout();
}
})
在移动设备(iphone和ipad)上,工具栏可以很好地渲染,但列表在我更改设备方向之前不会渲染
在chrome上,渲染效果很好。是否有人看到任何可能导致此问题的突出内容?通过将面板声明为全屏:true,它将在创建时(即在onReady之前)自动呈现到文档正文
不完全确定这是如何解决问题的。你能告诉我零钱是多少吗?就我所见,Envato.AudioJungle.Previewer.displayPanel已经有了“全屏:真”这就是重点。该类是用fullscreen:true声明的,这意味着它将尝试在实例化后立即呈现到文档体。在这种情况下,它在onReady之外。
Ext.namespace('Envato', 'Envato.AudioJungle', 'Envato.AudioJungle.Previewer', 'Envato.Stores');
Ext.setup({
onReady: function() {
Envato.AudioJungle.Previewer.displayPanel.render(Ext.getBody()).doComponentLayout();
}
})
Ext.setup({
onReady: function(){
Ext.regModel('Item', {
fields: ['text']
});
new Ext.Panel({
fullscreen: true,
layout: 'fit',
dockedItems: [{
xtype: 'toolbar',
items: {
text: 'I am a button'
}
}],
items: {
xtype: 'list',
itemTpl: '{text}',
store: new Ext.data.Store({
model: 'Item',
data: [{
text: 'Foo'
}]
})
}
});
}
});