流星/语义ui中的Bug
Bug in Meteor/Semantic-UI?
如果根元素是流星模板,则语义ui模态窗口的使用不起作用:
包:semantic-ui-css
错误复制:
hello.html:
<template name="hello">
<head>
<title>Hello Error</title>
</head>
<body>
<h1>Reproduce error</h1>
{{> navigation}}
<div class="delete openModal">OPEN<i class="close icon"></i></div>
<div id="modalView" class="ui modal">
<div class="content">
<div class="ui fluid input">
Modal Error Test
</div>
</div>
<div class="actions">
<div class="ui button cancel">Cancel</div>
<div class="ui button ok">OK</div>
</div>
</div>
</body>
</template>
<template name="navigation">
<div class="ui menu">
<a class="item" id="home" href="/">
<i class="home icon"></i> welcome
</a>
</div>
</template>
在Javascript (hello.js)代码中:
if (Meteor.isClient) {
Template.hello.events({
'click .openModal': function (event,template) {
$('#modalView')
.modal({
onDeny : function(){
console.log('canceled');
},
onApprove : function() {
console.log("yeah!");
}
})
.modal('show')
;
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
Router.route('/', function () {
this.render('hello');
});
错误是:
TypeError: $dimmer.on is not a function
semanti...27ec43c (Line 5786)
有人知道怎么解决这个问题吗?
根元素是模板不是问题。问题是在模板中有BODY
标记。你结束了两个BODY
标签,这导致有两个$调光器。所以当美元变暗时。当它被调用时,它实际上是一个数组,语义界面代码必须调用$dimmer[i]。On(这里我将是0和1),它不会这样工作
所以把hello.html改成:
<template name="hello">
<div class="delete openModal">OPEN<i class="close icon"></i></div>
<div id="modalView" class="ui modal">
<div class="content">
<div class="ui fluid input">
Modal Error Test
</div>
</div>
<div class="actions">
<div class="ui button cancel">Cancel</div>
<div class="ui button ok">OK</div>
</div>
</div>
</template>
<template name="navigation">
<div class="ui menu">
<a class="item" id="home" href="/">
<i class="home icon"></i> welcome
</a>
</div>
</template>
创建一个布局(layout.html):
<head>
<title>Hello Error</title>
</head>
<body>
<h1>Reproduce error</h1>
{{> navigation}}
</body>
。
当然你可以直接从hello.html:
中删除BODY
标签<template name="hello">
<head>
<title>Hello Error</title>
</head>
<h1>Reproduce error</h1>
{{> navigation}}
<div class="delete openModal">OPEN<i class="close icon"></i></div>
<div id="modalView" class="ui modal">
<div class="content">
<div class="ui fluid input">
Modal Error Test
</div>
</div>
<div class="actions">
<div class="ui button cancel">Cancel</div>
<div class="ui button ok">OK</div>
</div>
</div>
</template>
<template name="navigation">
<div class="ui menu">
<a class="item" id="home" href="/">
<i class="home icon"></i> welcome
</a>
</div>
</template>
这也可以,但我认为第一种方法是干净的/Meteor方式。
相关文章:
- jquery IE8 bug 中的 .on 方法
- WebView bug - 替换 ContentEditable 中的选定文本
- d3”;隐藏的“;属性bug或我代码中的bug
- FF中的JS Fine,Chrome中的bug
- Javascript Bug中的快速排序
- '中的格式化程序;带负堆叠的条形图':this.point.stackTotal的值错误(bug?)
- eclipse JavaScript开发工具中的bug代码完成
- 在Chrome/Safari中剥离表:tr:n -child td的bug
- 删除IE中的cookie bug
- 简单比较中的Javascript bug
- webkitTransform在safari中的bug ?我疯了吗?
- url get字符串中嵌套数组的Bug
- Ios 9移动safari在transform scale3d和translate3d中有一个闪烁的bug
- JavaScript中的本地文件支持检测- Windows Phone 8 Bug
- 扩展中的Bug:获取背景页面
- 我的JavaScript代码中的Bug:同步性问题
- 我的Javascript代码中的Bug:范围问题或逻辑问题
- Javascript数组(图像滑块)(Webkit中的bug ?)
- javascript函数中的Bug
- 流星/语义ui中的Bug