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

      0  

    Default Dynamic/variable "url" in ajax proxy

    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
    Location
    Stockholm, Sweden
    Posts
    563
    Vote Rating
    51
    tangix is a jewel in the rough tangix is a jewel in the rough tangix is a jewel in the rough

      0  

    Default


    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:
    Code:
    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.

    HtH,
    /Mattias

Thread Participants: 1