English 中文(简体)
在Sencha Touch 2 装上外部 j子的恰当方式
原标题:What is the proper way to load an external javascript in Sencha Touch 2

在我的发展中,我需要列入第三部分javascripts;与钱一样(http://jossulecroft.github.com/ money.js/)

实现这一目标的最佳清洁/适当方式是什么? 是否将其列入指数?

最佳回答

No. Don t direct 增加index.html文档中的javascript文档。 这并不是recommable(,但可以工作)。

相反,这样做是一样的。

  • Include the following line in your index.html. microloader is the folder that is shipped with sencha sdk and contains three files mainly, development.js, production.js and testing.js , each one for it s own purpose.

< script id = “microloader”打字=“text/javascript” src=”。

  • Then, in your <appname> folder, you will need to have a file called as app.json. It will look something like this ..
{
    "name": "Sencha",

     // All javascript files go here ...
    "js": [
        {
            "path": "../../sencha-touch-all-debug.js"
        },
        {
            "path": "app.js",
            "update": "delta"
        },
        { 
            "path": "http://josscrowcroft.github.com/money.js/",
            "update": "delta"  
        }
    ],
    "css": [
        {
            "path": "../../resources/css/sencha-touch.css",
            "update": "delta"
        },
        {
            "path": "resources/css/app.css",
            "update": "delta"
        }
    ],

    .....
    .....
    .....
 }
问题回答

If you are using Sencha Cmd your index.html may look like this:

<!-- The line below must be kept intact for Sencha Command to build your application -->
<script id="microloader" type="text/javascript" src=".sencha/app/microloader/development.js"></script>

因此,在改用背书后,你需要复读:

sencha app refresh

Pure javascript did the trick for me. I just included this block of code in the launch function:

var scriptTag = document.createElement( script );
scriptTag.src =  specify the path here... ;
document.body.appendChild(scriptTag);

The scriptTag gets appended into the body of your index file.

如果外部的贾瓦文图书馆是当地的话,下面为我做的是Ext JS 5.0.0。 编辑后,管理“sen灯”

Make changes to three JSON elememtns in app.json. (1) js (2) css (3) resources

{
    "name": "Sencha",

     // All javascript files go here ...
"js": [
    {
        "path": "app.js",
        "bundle": true
    },
    {
        "path": "leaflet/leaflet.js",
        "bundle": true
    }
],
"css": [
    {
        "path": "bootstrap.css",
        "bootstrap": true
    },
    {
        "path": "leaflet/leaflet.css",
        "bootstrap": true
    }
],

    .....
/**
 * Extra resources to be copied along when build
 */
"resources": [""leaflet/leaflet.js","leaflet/leaflet.css"

], ..... ..... }





相关问题
Windows 7 multitouch capabilities with HTML5

I have a problem: There are HTML5/CSS3 mobile frameworks on the market like Sencha Touch and Phonegap which can use the multi-touch gestures of the iPad/iPhone, Android, etc. That s working fine, I ...

Getting started with Sencha Touch

I m an Ext veteran but have a few rather simple mobile apps i need to create and naturally i m looking at sencha touch. Ting is - most of the examples don t run up in Firefox/Opera. I m happily using ...

Custom icon in TabPanel fails

I m trying to add a custom icon to a TabPanel but when I do that it just shows a dark box with rounded corners. My css looks like this: http://pastebin.org/447682 The code in the url is base64 for ...

Sencha Touch and ExtJS

Sencha Touch looks impressive, and ExtJS looks nice. I am evaluating if I should use ExtJS or SproutCore for an upcoming app. Now that Sencha Touch is in the mix, I wonder if I choose ExtJS, it d be ...

Turning Sencha Touch-based app into a true native iPhone app?

As I understand, Sencha Touch is just a javascript library that lets you create websites that respond to multitouch and other features you find in native iPhone apps. So... Your end result is accessed ...

Is anyone using Sencha Touch for mobile development?

We re evaluating Sencha Touch for mobile development. Has anyone used this yet (I realize that it s still in beta), and if so, what are its strengths / weaknesses? How does it compare to alternatives? ...

热门标签