0

我正在使用引导表单助手jquery 插件来帮助用户选择一个国家并查看标志。

index.html 当我放置所需的 html 时,我有一个包含所有模板的 ember 应用程序

<div class="bfh-selectbox bfh-countries" data-country="RW" data-flags="true"></div>

进入索引文件,我得到适当的下拉菜单。

在此处输入图像描述

当我将相同的 html 放入模板中时,说“关于”

<script type="text/x-handlebars" data-template-name="about">
<h3>About</h3>
<p>This is a basic application using Ember.js on the client side</p>
<div class="bfh-selectbox bfh-countries" data-country="RW" data-flags="true"></div>
</script>

index.html#/about当我通过单击链接直接访问时,代码不会显示。div 显示在控制台中,但样式不显示,它是不可见的。奇怪的是,当我刷新index.html#/about国家选择器显示时。

如何让这个 div 始终显示?

4

1 回答 1

0

您应该定义和 AboutView 并将代码添加到 didInsertElement 挂钩

App.AboutView = Ember.View.extend({
    didInsertElement: function(){
        this.$('form select.bfh-countries, span.bfh-countries, div.bfh-countries').each(function () {
          var $countries;
          $countries = $(this);
          if ($countries.hasClass('bfh-selectbox')) {
            $countries.bfhselectbox($countries.data());
          }
          $countries.bfhcountries($countries.data());
        });
    }
});

祝你好运

于 2013-11-06T15:45:31.363 回答