Giter VIP home page Giter VIP logo

Comments (6)

elmasse avatar elmasse commented on June 12, 2024

John,

I'm afraid that XHR is not supported to load local files which is the main problem with Phonegap and iOS. The Bundle-touch is implemented on top of DataStore using an AjaxProxy to query the server. I have to do some research about this issue but if you have more info please share it in here.

from ext.i18n.bundle-touch.

elmasse avatar elmasse commented on June 12, 2024

John,

I've found a workaround for your issue. You need to override a method in Ext.data.AjaxProxy to make it work inside phonegap. This is my workaround

Ext.data.AjaxProxy.override({

createRequestCallback: function(request, operation, callback, scope) {
    var me = this;

    return function(options, success, response) {

        if (success === true || (response.status === 0 && response.responseText !== "" )) { //fixing xhr to local files
            var reader  = me.getReader(),
                result  = reader.read(response),
                records = result.records,
                length  = records.length,
                mc      = new Ext.util.MixedCollection(true, function(r) {return r.getId();}),
                record, i;
            mc.addAll(operation.records);

            for (i = 0; i < length; i++) {
                record = mc.get(records[i].getId());

                if (record) {
                    record.set(record.data);
                }
            }

            //see comment in buildRequest for why we include the response object here
            Ext.apply(operation, {
                response : response,
                resultSet: result
            });

            operation.setCompleted();
            operation.setSuccessful();
        } else {
            me.fireEvent('exception', this, response, operation);

            //TODO: extract error message from reader
            operation.setException();                
        }

        //this callback is the one that was passed to the 'read' or 'write' function above
        if (typeof callback == 'function') {
            callback.call(scope || me, operation);
        }

        me.afterRequest(request, true);
    };
}   
});

You can put this into a file - I called AjaxPhonegapProxy.js - and load it after extjs files.
The main issue in here is that we have not a success response, instead we have a response with a status code 0, which is used by many browsers to indicate a success response for a non-valid xhr request like this using a file:// protocol.
So, if we need to make sure that first that code is 0 and then check that responseText has value to assume that xhr response is valid.

Let me know if it works for you.

Best!
Max

from ext.i18n.bundle-touch.

jbmurphyusa avatar jbmurphyusa commented on June 12, 2024

Thanks Max!

Will let you know as soon as I can. All day meeting today.

from ext.i18n.bundle-touch.

jbmurphyusa avatar jbmurphyusa commented on June 12, 2024

Yes Max that worked perfectly. However, the way that I incorporated the change was by putting the code directly into the sencha-touch-debug.js script.

I assume though that there is a way to "build" the consolidated Sencha library files from the individual files in src tree?

from ext.i18n.bundle-touch.

elmasse avatar elmasse commented on June 12, 2024

I wouldn't do that. Since it is just a workaround for phonegap, I would include that into a , let's say, ajaxLocalFix.js and include that file in the index.html so in case you need to change the SenchaTouch version you don't need to be aware of recreating the sencha file.

from ext.i18n.bundle-touch.

jbmurphyusa avatar jbmurphyusa commented on June 12, 2024

Right. agree. Thank you.

from ext.i18n.bundle-touch.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.