Sencha Touch Carousel 中的项目消失
我目前正在使用 Sencha Touch 构建一个应用程序。我们在包含多个项目的页面上有一个特定的轮播。单击不同面板上的按钮后,某些项目将添加到面板中或从面板中删除。
问题:第一次点击一切按计划进行,但是在再次点击同一按钮时,功能停止工作并且轮播显示变为空白,看不到任何项目。
下面是更改轮播内容的按钮处理程序itemsCarousel
。该函数将 itemPanels[ b.getBadgeText() ]
添加到 itemsCarousel
的项目中。对于前四次点击左右,这效果很好。在那之后,当我单击按钮时,轮播中的所有项目都会消失,并且我无法添加或删除任何更多内容,甚至无法从控制台手动调用轮播。
handler: function(b, e) {
itemsCarousel.insert(1, itemPanels[ b.getBadgeText() ]);
itemsCarousel.doLayout(); itemsCarousel.doComponentLayout();
itemsCarousel.setActiveItem(1);
itemsCarousel.remove(0, false);
}
我尝试过的事情:
- 通过在插槽
0
处插入项目、将0
设置为活动状态,然后删除1
来更改顺序。 - 在每一行上放置 javascript 断点,看看轮播在哪里变成空白。有时它出现在
.insert()
语句处,有时出现在.remove()
处。 - 从控制台手动完成所有这些操作。
- 调整
.remove()
调用(如上所示)和itemsCarousel
声明中的autoDestroy
参数。
如果您需要更多代码,我可以发布您认为可能相关的任何内容,我不想用多余的代码污染这个线程。感谢您的帮助!
编辑:如果有人知道重现相同功能的另一种方法,我也对此持开放态度。我正在考虑创建一个虚拟支架容器,其中包含一个项目、一个旋转木马,然后删除整个旋转木马并在单击按钮时重新添加一个全新的(包含新项目)?
I'm currently building an application using 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
. The function adds itemPanels[ b.getBadgeText() ]
to the itemsCarousel
's items. 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
, setting0
active, and then removing1
. - Putting javascript breakpoints on each of the lines, seeing where the carousel goes blank. Sometimes it occours at the
.insert()
statement, sometimes at the.remove()
. - Doing all this manually, from the console.
- Tweaking the
autoDestroy
parameter in the.remove()
call (as seen above) and in the declaration ofitemsCarousel
.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我想出了如何使用不同的方法重现该功能。
我构建了多个轮播,每个都包含我想要的面板,然后有一个根面板,可以根据按钮按下情况简单地设置活动轮播。例如,层次结构现在如下所示:
我执行 rootPanel.setActiveItem(x) 来显示新的轮播。
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:
and I perform
rootPanel.setActiveItem(x)
to display the new carousel.