【发布时间】:2012-01-09 21:04:28
【问题描述】:
我希望我在 Sencha touch 中的商店加载不同的 PHP 文件,具体取决于单击了轮播中的哪个项目。我的轮播中的每个项目都分配了 itemid: {number}。这是我现在的商店:
var store = new Ext.data.Store({
model: 'One',
proxy: {
type: 'ajax',
url: '/carousel2store/Carousel 2_files/get-album.php',
reader: {
type: 'json',
root: 'albums'
}
},....etc
我尝试过像这样改变商店,它给出“/carousel2store/Carousel 2_files/get-album2.php”,但我想让数字 2 动态化,所以点击时它会改变:
var store = new Ext.data.Store({
model: 'One',
proxy: {
type: 'ajax',
url: '/carousel2store/Carousel 2_files/get-album' + '2' +'.php',
reader: {
type: 'json',
root: 'albums'
}
},
我已尝试添加 itemid
url: '/carousel2store/Carousel 2_files/get-album' + '{itemid}' +'.php', and
url: '/carousel2store/Carousel 2_files/get-album' + '{data.itemid}' +'.php',
但到目前为止我还没有运气。 sencha 论坛上一位非常乐于助人的人建议我试试这个:
var store = new Ext.data.Store({
model: 'One',
proxy: {
type: 'ajax',
url: '/carousel2store/Carousel 2_files/get-album{itemId}.php',
reader: {
type: 'json',
root: 'albums'
}
}
});
store.proxy.url = store.proxy.url.replace('{itemId}', 1);
console.log(store);
...但是当我用鼠标单击时,我无法让它在我的测试中工作,我认为因为它已经在轮播和项目点击侦听器之前加载了商店(至少它对我不起作用我用鼠标测试)。我想我需要一种在商品点击后立即强制更新商店名称的方法。
提前致谢
:-)
【问题讨论】:
标签: url dynamic sencha-touch store carousel