PDA

View Full Version : Problem changing ScriptTagProxy url dynamically



ytpytp222
10 Mar 2012, 4:32 PM
I'm using a ComboBox containing a data store with ScriptTagProxy,



ds = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: 'solid part'+change part,
method:'post'
}),
reader: new Ext.data.JsonReader({
])
});

test = new Ext.form.ComboBox({
store: ds,
displayField:'title',
typeAhead: false,
loadingText: 'Searching...',
minChars:2,
minHeight:25,
width: 300,
pageSize:0,
hideTrigger:true,
tpl: resultTpl,
applyTo: 'test',
itemSelector: 'div.search-item',
onSelect: function(record){ // override default onSelect to do redirect
window.location = String.format('');
}
});




I want to change its proxy url dynamically like:


xxx.onclick=fun();
fun(){
ds.proxy.url="new url";
}
or
fun(){
ds.proxy.setUrl("");
}

I have tried many ways, but it does not work. If I change proxy to HttpProxy, this will work.
I use Illuminations to watch into the element, I find the url has been changed, but each time it send a request(type sth in the input), the url still do not change...
Hope someone can help me.
Thanks in advance

mitchellsimoens
11 Mar 2012, 6:48 AM
The ScriptTagProxy shouldn't have a setUrl method but if you change the url on the proxy itself it should work. I would step through the code and find out if it is using the new url and if it creates the <script> element.

ytpytp222
13 Mar 2012, 2:50 AM
The ScriptTagProxy shouldn't have a setUrl method but if you change the url on the proxy itself it should work. I would step through the code and find out if it is using the new url and if it creates the <script> element.

Thanks for reply.
I check the proxy using tool, the url has been changed, but the datastore seems has been initialized when combobox is created and cannot be changed(or change do not take effect). As after changing the proxy, each time I type in sth, the request url still do not change(the ComboBox is sth like a search input like examples provided officially)

I temporally write the part into session as a solution, for I'm really not very familiar with Extjs frame.