我希望我在 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。我发现这在大多数情况下特别有效,只要确保正确处理加载顺序即可。
store = Ext.StoreMgr.get('YourStore');
store.setProxy({
type: 'ajax',
url: 'http://www.yoururl.com?foo=bar',
});
关于url - 单击时 Sencha Touch 动态商店 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8329149/