流星应用程序中的按钮位置错误
Button in wrong place in meteor app
我做了一个小应用程序,我的按钮只显示在一个地方。这一切都在起作用,但在错误的地方。请参阅图片。我会留下我的GitHub回购链接。抱歉,大部分内容都是西里尔字母,但代码当然是英文拉丁字母。
这是我的问题的视频(22秒)
谢谢你的帮助。
您的问题是id
。HTML id
是唯一的,所以当您执行document.getElementById('skocko')
时,您只会返回具有该id的第一个元素。
相反,给按钮一个skocko
类,并像这样访问它:
Template.myTemplate.events({
"click .glasaj":function(event, template){
template.$(".skocko").toggle();
}
}
这将选择当前模板中类别为skocko
的元素。
SRC:https://stackoverflow.com/a/27116956/2317712
检查div定位如何使用jQuery相对于另一个元素定位一个元素?所以它的位置可以相对于点击的按钮,或者为每个skoko分配唯一的skoko id。。
在脚本glasaj.js 中执行类似操作
if (Meteor.isClient) {
Template.glasajDugme.events({
'click .glasaj': function(){
var g = Meteor.user().profile.неискоришћениГласови;
if (g < 1) {
var pos = $(this).position();
// .outerWidth() takes into account border and padding.
var width = $(this).outerWidth();
//show the menu directly over the placeholder
$("#skocko").css({
position: "absolute",
top: pos.top + "px",
left: (pos.left + width) + "px"
}).show();
document.getElementById('skocko').style.display = "inline-flex";
// return "disabled" ;
}
else {
Predlozi.update(this._id, {$inc: {Број_Гласова: 1}}
);
Meteor.users.update(Meteor.userId(), {$inc: {"profile.неискоришћениГласови": -1}}
);
};
}
});
sakrijskocka = function(){
document.getElementById('skocko').style.display = "none";
};
};
相关文章:
- 传单缩放控制位置错误
- 流星应用程序中的按钮位置错误
- imgAreaSelect插件在引导模式窗口中的位置错误
- 谷歌浏览器中的地理位置错误回调
- 使用 select2 时引导弹出框的位置错误
- 地理位置错误:用户拒绝了安卓地理位置
- document.位置错误处理
- 鼠标位置错误
- 尝试恢复浏览器时验证位置错误
- JQuery UI工具提示-工具提示的位置错误(在页面左侧,而不是按钮周围)
- D3-记号位置错误
- 角度材质日期选择器位置错误,Chrome除外
- 动态创建Div's、 外部Div的孩子,在Chrome中的位置错误,但在IE中是正确的
- qTip2在渲染时的位置错误
- 简单的jquery验证-自定义位置错误消息放置
- iPhone模拟器位置错误
- 什么是粒子系统位置错误
- 滚动位置错误在一个页面的网站
- 使用TrackballControls移动光线时,相机位置错误
- jQuery追加位置错误