Sencha Touch:设置自动加载以包含 html 文件

发布于 2024-11-03 14:09:36 字数 1759 浏览 0 评论 0原文

我在 Sencha Touch 中设置了一个带有 2 个选项卡的简单面板:

ToolbarDemo.views.Homecard = Ext.extend(Ext.TabPanel, {
    title: "home",
    iconCls: "home",
    defaults: {
        styleHtmlContent: true
    },
    items: [{
        title: 'Playlist',
        scroll: 'vertical',
        html: 'test'
    },{
        title: 'Comments',
        scroll: 'vertical',
        autoLoad: {url: 'disqus.html', scripts: true}
    }]
});

Ext.reg('homecard', ToolbarDemo.views.Homecard);

在“注释”选项卡上,我尝试包含一个 disqus.html 文件,该文件与我的应用程序的 index.html 文件处于同一级别,但没有显示任何内容向上。通过谷歌搜索,我似乎已经正确输入了自动加载代码,但也许我错过了另一个步骤?

有人可以帮助我吗?

谢谢,

Nick

Disqus 代码:

<div id="disqus_thread"></div>

    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'monthlymixup'; // required: replace example with your forum shortname

        // The following are highly recommended additional parameters. Remove the slashes in front to use.
        var disqus_identifier = 'test';
        // var disqus_url = 'http://example.com/permalink-to-page.html';

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

I have set up a simple panel in Sencha Touch with 2 tabs:

ToolbarDemo.views.Homecard = Ext.extend(Ext.TabPanel, {
    title: "home",
    iconCls: "home",
    defaults: {
        styleHtmlContent: true
    },
    items: [{
        title: 'Playlist',
        scroll: 'vertical',
        html: 'test'
    },{
        title: 'Comments',
        scroll: 'vertical',
        autoLoad: {url: 'disqus.html', scripts: true}
    }]
});

Ext.reg('homecard', ToolbarDemo.views.Homecard);

On the 'Comments' tab I am trying to include a disqus.html file which is at the same level as the index.html file for my app, but nothing is showing up. From googling about it would seem that I have entered the autoload code correctly, but perhaps I have missed out another step?

Could someone help me on my way?

Thanks,

Nick

Disqus code:

<div id="disqus_thread"></div>

    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'monthlymixup'; // required: replace example with your forum shortname

        // The following are highly recommended additional parameters. Remove the slashes in front to use.
        var disqus_identifier = 'test';
        // var disqus_url = 'http://example.com/permalink-to-page.html';

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

王权女流氓 2024-11-10 14:09:36

“autoLoad”属性仅在 ext.js 中存在,在 sencha-touch 中尚不可用。

但你可以这样做(你的里程会有所不同):(

Ext.setup({
onReady: function() {
    var tabPanel = new Ext.TabPanel({
        fullscreen: true,
        type: 'dark',
        sortable: true,
        items: [{
            title: 'Tab 1',
            html: '1',
            cls: 'card1',
        }, {
            title: 'Tab 2',
            html: '2',
            cls: 'card2'
        },
        {
            title: 'Tab 3',
            html: '3',
            cls: 'card3'
        }]
    });
    Ext.Ajax.request({
      url: 'disqus.html',
      success: function(response, opts) {
      tabPanel.items.get(2).update(response.responseText, true);  //2nd parameter is "loadScripts"
    }
    });
  }
});

disqus.html)

<html>
  <head>
  </head>
  <body>Hello World.</body>
</html>

The "autoLoad" property is only in ext.js and not yet available in sencha-touch.

But you can do something like this (Your mileage WILL vary):

Ext.setup({
onReady: function() {
    var tabPanel = new Ext.TabPanel({
        fullscreen: true,
        type: 'dark',
        sortable: true,
        items: [{
            title: 'Tab 1',
            html: '1',
            cls: 'card1',
        }, {
            title: 'Tab 2',
            html: '2',
            cls: 'card2'
        },
        {
            title: 'Tab 3',
            html: '3',
            cls: 'card3'
        }]
    });
    Ext.Ajax.request({
      url: 'disqus.html',
      success: function(response, opts) {
      tabPanel.items.get(2).update(response.responseText, true);  //2nd parameter is "loadScripts"
    }
    });
  }
});

(disqus.html)

<html>
  <head>
  </head>
  <body>Hello World.</body>
</html>
荒路情人 2024-11-10 14:09:36

我想带一段用于获取外部 html 的代码。正如您可能注意到的,您应该使用回调,而不是成功函数。不知道为什么,通常结果会导致功能失败。

    Ext.Ajax.request({
        url: url,
        method: 'GET',
        callback: function(options, success, response) {
            // do what you need with response.responseText
            // I'm updating a panel with styleHtmlContent: true,
        }
    });

I'd like to bring a piece of code that I use to get an external html. As you may note, you should use callback, instead of success function. Not sure why, often the result goes to failure function.

    Ext.Ajax.request({
        url: url,
        method: 'GET',
        callback: function(options, success, response) {
            // do what you need with response.responseText
            // I'm updating a panel with styleHtmlContent: true,
        }
    });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文