我试图让jscolor(http://jscolor.com/)在我的流星应用程序上运行。
jscolor.js javascript文件位于:
client/lib/jscolor.js
现在我在main.html中输入了一个带有类jscolor的输入元素,如:
<head>
<title>Meteor Site</title>
</head>
<body>
<input class="jscolor" value="ab2567">
</body>
它有效!但是只要我把它放在一个由铁路由器控制的模板中,例如设置:
<template name="settings">
Settings
<input class="jscolor" value="ab2567">
</template>
它什么都不做,它保持常规输入字段。我是否需要以某种方式将javascript文件传递给模板,还是需要将其设置为全局?希望有人可以帮助我吗?
答案 0 :(得分:1)
meteor add risul:bootstrap-colorpicker
html file
<template name="hello">
<input type="text" class="demo1" value="#5367ce" />
</template>
js file
Template.hello.rendered = function() {
$('.demo1').colorpicker();
}