UIKit的手风琴和NG-重复不起作用 [英] UIKit accordion and ng-repeat doesn't work

查看:118
本文介绍了UIKit的手风琴和NG-重复不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我动态地添加新的手风琴节对我的UIKit数据-UK-手风琴,采用NG-重复。

I'm adding new accordion sections to my UIKit data-uk-accordion dynamically, using ng-repeat.

<div class="uk-accordion" data-uk-accordion="{ collapse: false }">
  <h3 class="uk-accordion-title uk-active" ng-repeat-start="driver in drivers">Driver {{driver.id}}</h3>
  <div class="uk-accordion-content" ng-repeat-end>
  ...
</div>

当我添加新的手风琴节,我点击标题崩溃,我得到了以下错误:

When I add new accordion sections and I click on the title to collapse, I'm getting the following error:

类型错误:包装是不确定的,在UIKit中2.24.2 accordion.js线73:
wrapper.data('切换')toggleClass(this.options.clsactive);

TypeError: wrapper is undefined, on line 73 of accordion.js in UIkit 2.24.2: wrapper.data('toggle').toggleClass(this.options.clsactive);

我尝试添加数据-UK-观察手风琴格,或者其母公司申报单,但没有任何效果,也可手动试图通过重新初始化到手风琴从控制台,但没有改变其添加一个id,并运行UIkit.accordion('#司机')

I tried adding data-uk-observe to the accordion div, or its parent divs but didn't have any effect, and also tried to reinit the accordion manually by adding it an id, and running UIkit.accordion('#drivers') from console but no change.

甚至试图从控制台运行 UIkit.init(),但我得到了同样的错误。

Even tried to run UIkit.init() from console but I'm getting the same error.

任何想法如何重新初始化手风琴?

Any ideas how to reinit the accordion?

推荐答案

它看起来像你想要做的是:

It looks like what you want to do is:


  • 忽略数据-UK-手风琴属性。

  • 保存对象从调用 UIkit.accordion(元素,期权)返回。

  • 后,新的手风琴子元素已被添加,呼叫 accordion.update()
  • (假设你在一个名为手风琴变量保存上述返回的对象)
  • Omit the data-uk-accordion attribute.
  • Save the object returned from calling UIkit.accordion(element, options).
  • After new accordion child elements have been added, call accordion.update(). (assuming you saved the returned object above in a variable called accordion)

有关如何我初来乍到的更多信息,请href=\"https://github.com/uikit/uikit/issues/1659\" rel=\"nofollow\"> GitHub上的有关问题

For more information about how I arrived at that, check out the related issue on GitHub.

这篇关于UIKit的手风琴和NG-重复不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆