1. #1
    Sencha User
    Join Date
    Mar 2013
    Vote Rating
    screamdev is on a distinguished road


    Default Dynamic/variable "url" in ajax proxy

    I'm trying to find a way to dynamically change the 'url' part of the Ext.data.proxy.Server in my ajax stores.

    Currently, Architect only accepts a String value like 'http://whatever.com', but this is restrictive for me, because while the application is running, I'd like to be able to switch to a different url on all stores at the same time.

    Any help would be appreciated.

    Thank you.

  2. #2
    Ext JS Premium Member tangix's Avatar
    Join Date
    Mar 2010
    Stockholm, Sweden
    Vote Rating
    tangix is a jewel in the rough tangix is a jewel in the rough tangix is a jewel in the rough tangix is a jewel in the rough



    I suggest putting that logic in a central function setting up the proxies for the different stores. I have 20+ Stores that I configure along the lines:
    Ext.getStore('CertStore').getProxy().url = UP8.config.backend + 'certs';
    Ext.getStore('ActiveVoucherStore').getProxy().url = UP8.config.backend + 'vouchers/active';
    Ext.getStore('RedeemedVoucherStore').getProxy().url = UP8.config.backend + 'vouchers/redeemed';
    Ext.getStore('CreditStore').getProxy().url = UP8.config.backend + 'credits';
    Ext.getStore('ExamStore').getProxy().url = UP8.config.backend + 'exams';
    In the app.init() function and the UP8.config is set by the server in the app.html that is generated when the user access the page.
    While I haven't tried changing the URL on the fly at least this lets me set the url in SA to something that makes sense while developing (to get bogus data from the backend) and when actually running in a browser the init() is executed and all is working.


Thread Participants: 1