I would like my store in Sencha touch to load a different PHP file depending on which item in my carousel is clicked. Each item in my carousel has itemid: {number} assigned. This is my store at the moment:
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
I’ve tried altering the store like this which gives ‘/carousel2store/Carousel 2_files/get-album2.php’, but I would like to make the number 2 dynamic, so it changes on click:
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'
}
},
I’ve tried to add the itemid
url: '/carousel2store/Carousel 2_files/get-album' + '{itemid}' +'.php', and
url: '/carousel2store/Carousel 2_files/get-album' + '{data.itemid}' +'.php',
But I’ve had no luck so far. A very helpful guy on the sencha forum suggested I try this:
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);
…but I can’t get it to work in my testing when clicking with the mouse, I think because it loads the store already before the carousel and item tap listener (at least it didn’t work for me in my testing with the mouse). I think I need a way of force updating the store name straight after item click.
Thanks in advance
🙂
I had a somewhat similar problem where I need to dynamically change the URL on my proxy. I found that this works particularly well in most cases, just be sure to handle your load sequence properly.