2

我通过以下方式在 Meteor 0.9.1.1 中实现了 iCheck:

icheck.js 和 Meteor 应用程序

但 Firebug 告诉我, .iCheck 不是一个函数。

我刚刚添加了 jQuery

Meteor add jquery

所以我想我有它的最新版本,它应该提供.iCheck。还是它使用旧版本的 jQuery?

4

1 回答 1

6

这就是我让它工作的方式:

  1. iCheck-master从 github 存储库下载并解压缩。
  2. 复制icheck.jsclient/lib/
  3. 复制您想要的主题的css client/config/(例如skins/flat/red.css:)
  4. 复制您想要的主题的图像public/img/icheck/(例如:skins/flat/red.pngskins/flat/red@2x.png
  5. 编辑 css 以正确引用图像(例如:替换red.png/img/icheck/red.png

完成此操作后,您现在可以iCheck像这样在您的应用程序中使用:

client/views/icheck-test/icheck-test.html

<template name="icheck_test">
  <label>
    <input type="checkbox" name="foo">
    Foo
  </label>
</template>

client/views/icheck-test/icheck-test.js

Template.icheck_test.rendered=function(){
  this.$("input").iCheck({
    checkboxClass: "icheckbox_flat-red",
    radioClass: "iradio_flat-red"
  });
};

可以重复此过程以在 Meteor 中集成几乎任何 jQuery 插件。我们也可以使用包,但目前自定义包以选择特定主题有点棘手。

于 2014-09-15T12:37:51.730 回答