简体   繁体   English

Sencha Touch Carousel中的项目消失

[英]Items in Sencha Touch Carousel disappearing

I'm currently building an application using Sencha Touch. 我目前正在使用Sencha Touch构建应用程序。 We have a certain Carousel on a page that contains multiple items. 我们的页面上有一个特定的轮播,其中包含多个项目。 Upon clicking a button on a different panel, certain items are added and removed to the panel. 单击其他面板上的按钮后,某些项目将添加到面板中或从中删除。

The problem : all works as planned for the first click , but clicking upon clicking the same button again , the functionality stops working and the Carousel display turns blank, with none of the items visible. 问题 :所有操作均按计划进行,但第一次单击再次单击该按钮 ,该功能停止工作,并且“轮播”显示变为空白,没有任何项目可见。

Below is the handler for the buttons that change the content of the carousel itemsCarousel . 下面更改转盘的内容的按钮处理程序 itemsCarousel The function adds itemPanels[ b.getBadgeText() ] to the itemsCarousel 's items. 该函数将itemPanels[ b.getBadgeText() ]itemsCarousel的项目中。 For the first four clicks or so, this works great. 对于前四次点击,效果很好。 After around then, when I click a button, all the items in the Carousel vanish, and I cannot add or remove any more content, even invoking the Carousel manually from the console. 大约过一会儿,当我单击一个按钮时,“轮播”中的所有项目都消失了,甚至无法从控制台手动调用“轮播”,也无法添加或删除更多内容。

handler: function(b, e) {
    itemsCarousel.insert(1, itemPanels[ b.getBadgeText() ]);
    itemsCarousel.doLayout(); itemsCarousel.doComponentLayout();
    itemsCarousel.setActiveItem(1);
    itemsCarousel.remove(0, false);
}

Things I have attempted: 我尝试过的事情:

  • Changing the order by inserting the item at slot 0 , setting 0 active, and then removing 1 . 通过将项目插入插槽0 ,将0设置0活动,然后移除1更改顺序。
  • Putting javascript breakpoints on each of the lines, seeing where the carousel goes blank. 在每行上放置javascript断点,查看轮播的空白处。 Sometimes it occours at the .insert() statement, sometimes at the .remove() . 有时它出现在.insert()语句中,有时出现在.remove()
  • Doing all this manually, from the console. 从控制台手动完成所有这些操作。
  • Tweaking the autoDestroy parameter in the .remove() call (as seen above) and in the declaration of itemsCarousel . .remove()调用(如上所示)和itemsCarousel的声明中调整autoDestroy参数。

If you need more code I can post whatever you think may be relevant, I didn't want to pollute this thread with excess code. 如果您需要更多代码,我可以发布您认为相关的任何内容,但我不想用过多的代码来污染该线程。 Thanks for your help! 谢谢你的帮助!

Edit: If anyone knows another way to reproduce the same functionality, I am open to that as well. 编辑:如果有人知道另一种方法来重现相同的功能,我也很乐意。 I am thinking perhaps creating a dummy holder Container with one item, a carousel, and deleting the entire carousel and re-adding a brand new (with the new items) one upon the button click? 我正在考虑也许创建一个带有一个项目(一个转盘)的虚拟容器容器,并删除整个转盘并在单击按钮时重新添加一个全新的(带有新项目)一个?

Well, I figured out how to reproduce the functionality using a different method. 好吧,我想出了如何使用其他方法重现功能的方法。

I built multiple carousels, each containing the panels I wanted, and then had a root panel that simply sets the active carousel based on button presses. 我构建了多个轮播,每个轮播都包含我想要的面板,然后有一个根面板,该面板简单地根据按钮的按下来设置活动的轮播。 For example, the hierarchy looks like this now: 例如,层次结构如下现在这个样子:

rootPanel
{
    carousel[0]
    {
        panel1
        panel2
    }
    carousel[1]
    {
        panel3
        panel4
    }
    ...
}

and I perform rootPanel.setActiveItem(x) to display the new carousel. 然后执行rootPanel.setActiveItem(x)来显示新的轮播。

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

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