简体   繁体   English

ExtJS:如何在特定的“Window”组件上加载附加脚本?

[英]ExtJS: How to load additional script on a specific `Window` component?

I'm try to create a Window which will show AddToAny share buttons .我正在尝试创建一个Window ,它将显示AddToAny 共享按钮 I need to set AddToAny 's required script under this window.我需要在此窗口下设置AddToAny所需的script I've google similar question within Social Media buttons.我在社交媒体按钮中搜索了类似的问题。

  • I learned that Mashup class could work.我了解到Mashup类可以工作。 I've create a mixin class but unfortunately this is not working.我创建了一个mixin类,但不幸的是这不起作用。
  • As well saved related JS library under project files and tried to call it through html config but this isn't work either.同样在项目文件下保存了相关的 JS 库,并尝试通过html配置调用它,但这也不起作用。

How can I achieve to my aim?我怎样才能达到我的目标?

//Here is related function. 
onMoreShare: function () {
        new Ext.window.Window({
            // requires: ['MyApp.mixins.ShareApps'], //Tried to load JS file to Window
            title: 'More...',
            autoShow: true,
            modal: true,
            padding: 20,
            html: '<a class="a2a_dd" href="https://www.addtoany.com/share"><img src="https://static.addtoany.com/buttons/share_save_171_16.png" width="171" height="16" border="0" alt="Share"></a>\n' +
            // Mixin didn't work; tried original code...
            // '<script async src="https://static.addtoany.com/menu/page.js"></script>\n' +
            // Mixin didn't work; tried to call js file through project
            //'<script type="text/javascript" src="../../../resources/js/addToAny.js"></script>\n'
        });
    }

//Created this `Mashup` based class to load related JS file.
Ext.define('MyApp.mixins.ShareApps', {
    mixins: ['Ext.mixin.Mashup'],

    requiredScripts: [
        '//static.addtoany.com/menu/page.js'
    ]
});

Take a look at this fiddle:看看这个小提琴:

FIDDLE小提琴

Ext.application({
    name : 'Fiddle',

    launch : function() {
        Ext.widget('window', {
            width: 300,
            height: 250,
            padding: 5,
            title: 'Hello World',
            html: '<div class="a2a_kit a2a_kit_size_32 a2a_default_style"> '+
                  '<a class="a2a_dd" href="https://www.addtoany.com/share"></a> '+
                  '<a class="a2a_button_facebook"></a> '+
                  '<a class="a2a_button_twitter"></a> '+
                  '<a class="a2a_button_google_plus"></a> '+
                  '</div>'
        }).show();
    }
});

Index page:索引页面:

<html>
    <head>
        <script async src="https://static.addtoany.com/menu/page.js"></script>
    </head>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM