zoukankan      html  css  js  c++  java
  • Load a script file in sencha, supports both asynchronous and synchronous approaches

    //http://www.sencha.com/forum/showthread.php?188318-Ext.Loader.loadScriptFile-wrong-URL
    Ext.Loader.loadScriptFile("/a.js", function() {
        console.log('hello loadScriptFile callback'); }, undefined, true
    );

    //you can load script from local

    //and also, you can load script from remote server

    //for example,you can load a jquery lib from jquery CDN

    Ext.Loader.loadScriptFile("http://code.jquery.com/jquery-2.0.3.js", function() {
        console.log('hello loadScriptFile callback'); }, undefined, true
    );
    //you now can use jquery functions
    console.log($('body')[0].innerHTML)
    //above will error,you can't use $ at this place this moment, because the Loader loading files async,your code is not loaded just now
    // you can try
    //http://www.sencha.com/forum/showthread.php?188318-Ext.Loader.loadScriptFile-wrong-URL
    Ext.Loader.loadScriptFile("http://code.jquery.com/jquery-2.0.3.js", function() {
        console.log('hello loadScriptFile callback');  
        //once your script load successfully, you can use your functions from the new imported lib
        console.log($('body')[0].innerHTML);
        }, undefined, true
    );
  • 相关阅读:
    读取数据变JSON传值!
    YII2.0多条件查询升级版
    JS跳转页面方法
    yii的简单片段缓存
    我读过的最好的epoll讲解--转自”知乎“
    I/O多路复用详解
    ”open-close"prinple (OCP)
    获取本机的IPv4或者v6地址
    .Net 下未捕获异常的处理
    TCP断开连接的过程
  • 原文地址:https://www.cnblogs.com/zyip/p/3531882.html
Copyright © 2011-2022 走看看