ChatGPT
ChatGPT

Reputation: 5617

meteor event handler suppression issue

Here is my button click handler:

Template.kanjifinder.events({
  'click input.btnOK': function () {
    console.log("click");
        SetCharacters();
      }
});

But after I add the event handler below for my text input the above button click code has stopped working.

Template.kanjifinder.events = ({
'keydown input.txtQuery': function (evt) {
  if (evt.which === 13) {
     SetCharacters();
  }
 }
});

How can I get both the keydown event handler and the button click event handler working?

Upvotes: 0

Views: 108

Answers (1)

Tarang
Tarang

Reputation: 75945

Don't use the =

Template.kanjifinder.events({
'keydown input.txtQuery': function (evt) {
  if (evt.which === 13) {
     SetCharacters();
  }
 }
});

Also you can use both together in one:

Template.kanjifinder.events({
    'click input.btnOK': function () {
        console.log("click");
        SetCharacters();
    },
    'keydown input.txtQuery': function (evt) {
        if (evt.which === 13) {
            SetCharacters();
        }
    }
});

Upvotes: 3

Related Questions