Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

WebView external JS broken after update from 3.2.0 to 3.2.1

$
0
0

Hello,

I've recently updated from TI 3.2.0 to 3.2.1. I've got a local webview which references a couple local javascript files. In 3.2.0 I was able to pull those files in using relative references:

<link href="photoswipe.css" media="all" rel="stylesheet" type="text/css"/>
<script src="klass.min.js" type="text/javascript"></script>
<script src="code.photoswipe-3.0.4.min.js" type="text/javascript"></script>
After the 3.2.1 upgrade I get the error: file:///android_asset/Resources/old/app/photoSwipe/code.photoswipe-3.0.4.min.js

I checked the Resources folder, and the files are there. I did some googling, and found this: http://stackoverflow.com/questions/10960891/how-to-access-local-css-files-in-external-html-file. I changed the references to absolute references using the app:// notation:

<link href="app://Resources/old/app/photoSwipe/photoswipe.css" media="all" rel="stylesheet" type="text/css"/>
<script src="app://Resources/old/app/photoSwipe/klass.min.js" type="text/javascript"></script>
<script src="app://Resources/old/app/photoSwipe/code.photoswipe-3.0.4.min.js" type="text/javascript"></script>
I no longer get the error in the logs, but the inline Javascript can't find the objects that it expects anymore. It expects window.Code to resolve, but that is coming back as undefined now. I'm not sure if the reference is now just failing silently or if their is something else I'm missing.

Here's the full file:

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width,user-scalable=0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0"/>
    <link href="app://Resources/old/app/photoSwipe/photoswipe.css" media="all" rel="stylesheet" type="text/css"/>
    <script src="app://Resources/old/app/photoSwipe/klass.min.js" type="text/javascript"></script>
    <script src="app://Resources/old/app/photoSwipe/code.photoswipe-3.0.4.min.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
<script>
window.onload = function() {
    Ti.App.addEventListener('goPhotos', function(e) {
        var photos = e.photos;
        var index = e.index;
 
        var list = [];
        for (var i = 0, count = photos.length; i < count; i++) {
            var photo = photos[i];
            list.push({
                url:photo,
                caption:'Showing ' + (i+1) + ' of ' + photos.length
            });
        }
        var instance = window.Code.PhotoSwipe.attach(list, {
            captionAndToolbarFlipPosition: true,
            captionAndToolbarAutoHideDelay: 0,
            preventHide:true,
            preventSlideshow:true,
            getImageSource: function(obj) {
                return obj.url;
            },
            getImageCaption: function(obj) {
                return obj.caption;
            }
        });
        instance.show(parseInt(index));
    });
};
</script>
Does anyone have any idea how to fix this? I'm testing on a Nexus 5.

Thanks.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>