剑道UI不与流星合作
Kendo UI Not Working with Meteor?
我正在尝试在Meteor中使用一个简单的MultiSelect。在查看了大约20个不同的UI库后,我认为Kendo UI看起来最好。
我环顾四周,发现他们已经设置了流星包,可以(据说)在流星中轻松使用剑道UI。以下是我在Meteor:中使用Kendo UI尝试获得MultiSelect的Hello World的步骤
meteor create FindMeFood
meteor add telerik:kendo-ui-core-fiori-theme
然后我修改了FindMeFood.html
:
<head>
<title>FindMeFood</title>
</head>
<body>
<label for="where">Where</label>
<select id="where" multiple="multiple" data-placeholder="Select where...">
<option>McDonalds</option>
<option>Burger King</option>
<option>Wendy's</option>
<option>Five Guys</option>
<option>KFC</option>
<option>Taco Bell</option>
<option>Pizza Hut</option>
<option>Papa Johns</option>
</select>
</body>
最后修改FindMeFood.js
:
if (Meteor.isClient) {
$("#where").kendoMultiSelect().data("kendoMultiSelect");
}
什么也没发生。当我启动Meteor
并访问该页面时,我得到了一个标准的多选框。
如果您不想在这一点上搞砸,只需使用
关于meteor version 1.0.4 or >
if(Meteor.isClient){
Template.body.onRendered(function(){
$("#where").kendoMultiSelect().data("kendoMultiSelect");
})
}
Meteor 1.0.4 or less
if(Meteor.isClient){
Template.body.rendered = function(){
$("#where").kendoMultiSelect().data("kendoMultiSelect");
}
}
为什么选择rendered function()
?使用rendered函数,可以确保代码在DOM准备就绪时运行,在本例中为#where select
流星是客户端方法可能在客户端呈现HTML之前运行。
试着这样做,效果很好:
-
在
.html
文件中引入一个命名模板:<head> <title>FindMeFood</title> </head> <body> {{> kendo}} </body> <template name="kendo"> <label for="where">Where</label> <select id="where" multiple="multiple" data-placeholder="Select where..."> <option>McDonalds</option> <option>Burger King</option> <option>Wendy's</option> <option>Five Guys</option> <option>KFC</option> <option>Taco Bell</option> <option>Pizza Hut</option> <option>Papa Johns</option> </select> </template>
-
将
onRendered
函数添加到该模板(在js代码中):if (Meteor.isClient) { Template.kendo.onRendered(function () { $("#where").kendoMultiSelect().data("kendoMultiSelect"); }); }
-
选择多个地点玩得开心。
相关文章:
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- jQuery UI自动完成突然停止工作
- 如何使用skip参数使用angular ui引导进行服务器端分页
- AngularJS UI路由器不能像ng路由器那样工作
- 我可以更改剑道UI网格吗's的外键值
- 剑道UI内联编辑:如何在点击其他按钮时隐藏按钮
- 如何使用铁流星与流星的默认路线
- Rails/JSON:如何将JSON用于jquery UI自动完成表单
- 剑道UI不与流星合作
- 流星:UI 在反应性更改之间缓动收集项
- 如何使用引导导航栏构建我的流星烈焰 UI
- 流星:帐户-UI 包
- 流星和语义UI,模态获取价值
- 绑定语义-流星模板中的ui模块事件
- 流星新的应用程序结构减慢了ui文件夹的开发速度
- ui-router resolve中的流星集合
- 如何在流星项目中引导之前调用jquery-ui以防止冲突
- 流星框架中的全局对象UI是什么,应该如何使用
- 我如何提交一个实时验证的表单与语义UI和流星
- 流星/语义ui中的Bug