Unanswered: Newbie working using panel.hide() through multiple layers.
Unanswered: Newbie working using panel.hide() through multiple layers.
I have a Ext.list() of items in on an initial page. When you click an item an .on() listener fires creating an Ext.Panel() which has a Ext.List() of items in it. When you click one of these items an .on() listener fires creating a third Ext.Panel() with the content detail in it is created. However my back button from the third panel fails on the panel.hide() method. The error is Property '1' of object function (e, args) is not a function.
var contentBlock = new Ext.Panel({
height: 730,
title: '',
id: 'mainContent',
items: [sectionStories],
});
var device_detection = function(){
if (Ext.is.iPad) {
contentBlock.setSize({height:730});
return 'ipad';
} else if (Ext.is.iPhone || Ext.is.iPod) {
contentBlock.setSize({height:400});
return 'iphone';
} else if (Ext.is.Android) {
return 'android';
} else if (Ext.is.Mac) {
contentBlock.setSize({height:730});
return 'mac';
} else {
return 'none';
}
};
var addLogoToHomescreen = new Ext.Container({
floating : true,
html : '<p><span class="tip">TIP:</span> To put our icon on your homescreen press the plus then "add to homescreen"</p>',
padding : 10,
baseCls : device_detection() + '_icon_encouragement'
});
// Create the header
var header = new Ext.Panel({
id: 'header',
height: 121,
html: '<div id="header"><h1><a href="/"><img src="{{ STATIC_MEDIA_URL }}mobile/img/arkansasonline-mobile_logo_e2.jpg" alt="Arkansas Online Mobile"></a></h1></div>'
});
// Create the wrapper (which has the fixed height header and scroller)
var wrapper = new Ext.Panel({
fullscreen: true,
layout: {
type: 'vbox',
align: 'stretch'
},
items: [header, contentBlock],
dockedItems: [addLogoToHomescreen,navBar],
padding:10,
baseCls: 'x-wrapper'
});
sectionStories.on('itemtap', function(dataView, index, item, e){
var this_section = dataView.store.data.items[index].data;
console.log(this_section.name + ' tapped');
var sectionToolbar = new Ext.Toolbar({
dock : 'top',
title: this_section.name,
items: [
{text: 'Back',
ui: 'back',
handler: function(){
section_panel.hide();
}}
]
});
console.log(this_section.section_id)
storyLocalStore.clearFilter(true);
storyLocalStore.filter('section_id', this_section.section_id, false, false);
var section_panel = new Ext.Panel({
id : 'sectionPanel',
fullscreen : true,
scroll : 'vertical',
showAnimation: 'slide',
floating : true,
dockedItems: [sectionToolbar,],
items: [list]
});
section_panel.show();
});
list.on('itemtap', function(dataView, index, item, e){
var this_story = dataView.store.data.items[index].data;
console.log(this_story.headline + ' tapped');
var template = new Ext.XTemplate(
'<div class="story_content" style="padding:20px;">',
'<h1>{headline}</h1>',
'<h2>{subhead}</h2>',
'{large_thumbnail}',
'<p><strong>{pub_date}</strong></p>',
'{story}',
'<p>{post_story_blurb}</p>',
'</div>'
);
var str = template.apply(this_story);
var storyToolbar = new Ext.Toolbar({
dock : 'top',
title: 'Story',
items: [
{
text: 'Close',
ui: 'back',
handler: function(){
story_panel.hide();
}
}
]
});
var story_panel = new Ext.Panel({
id : 'storyPanel',
fullscreen : true,
scroll : 'vertical',
showAnimation: 'slide',
floating : true,
dockedItems: [storyToolbar],
html: str
});
story_panel.show();
});
}
});
Best way to do this is via a Panel with 'card' layout having 2 items. 1st item will be a list and 2nd item will be Panel with 'card' layout and so on. In Back button handler use Panel's setActiveItem API to switch to previous card.