이벤트의 유성 구현 또는 일반적으로 자바 스크립트 이벤트와 관련된 문제가 있습니다.유성 : 변경 이벤트가 동시에 발생하면 클릭 이벤트가 발생하지 않습니다.
"변경"이벤트에 첨부 된 텍스트 상자가 있습니다. 그 옆에는 "클릭"이벤트에 연결된 단추가 있습니다.
텍스트 상자를 변경하고 단추를 클릭하면 클릭 이벤트가 발생하지 않습니다 (변경 이벤트 만 수행). 클릭 이벤트가 발생하면 버튼을 두 번 클릭해야합니다.
Firefox에서는 click 이벤트 대신 mousedown 이벤트를 첨부하면 작동합니다. Chrome에서는 어느 쪽이든 작동하지 않습니다.
미리 감사드립니다.
최소한의 코드 문제 재현 :
이자바 스크립트가 : testevent.js를
if (Meteor.isClient) {
Session.set("something", "something");
Template.hello.foo = function() {
return Session.get("foo");
};
Template.hello.something = function() {
return Session.get("something");
}
Template.hello.events({
'click .buttonid' : function() {
console.log("click !");
},
'change .textid' : function (e,t) {
console.log("change !");
var bar = e.target.value;
Session.set("foo",bar);
}
});
}
if (Meteor.isServer) {
Meteor.startup(function() {
// code to run on server at startup
});
}
HTML : testevent.html
<head>
<title>testevent</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<input type="text" class="textid" value="{{foo}}"/>
<input type="button" class="buttonid" value="{{something}}" />
</template>
내가 ID를 클릭 이벤트 화재 클래스를 대체하지만, 같은 id를 가진 여러 필드가있을 때 이벤트는 하나의 필드에서만 작동합니다.
문제를 검사하기 위해 템플릿과 컨트롤러 코드를 최소화하는 것이 좋습니다. –
나는 문제를 demosntrating 몇 가지 최소한의 코드를 추가했습니다. –
코드를 제공해 주셔서 감사합니다. 불행히도 내 컴퓨터 (Ubuntu 13.04)에서 문제를 재현 할 수 없습니다. FF와 크롬 모두에서 버튼을 클릭 할 때'change' 및'click' 이벤트가 발생합니다. –