ExtJS:如何在特定的`Window`组件上加载其他脚本?

问题描述 投票:0回答:1

我试着创建一个Window,它将显示AddToAny share buttons。我需要在此窗口下设置AddToAny所需的script。我在社交媒体按钮中搜索类似的问题。

  • 我了解到Mashup课程可以奏效。我创建了一个mixin类但不幸的是这不起作用。
  • 同样在项目文件下保存相关的JS库,并尝试通过html配置调用它,但这也不起作用。

我怎样才能实现我的目标?

//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'
    ]
});
javascript extjs window share mixins
1个回答
1
投票

看看这个小提琴:

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();
    }
});

索引页面:

<html>
    <head>
        <script async src="https://static.addtoany.com/menu/page.js"></script>
    </head>
</html>
© www.soinside.com 2019 - 2024. All rights reserved.