Meteor Page Refreshing with Button Click

前端 未结 1 847
陌清茗
陌清茗 2020-12-21 20:22

I was following some code here: http://code.tutsplus.com/tutorials/real-time-messaging-for-meteor-with-meteor-streams--net-33409

To build a chat app. I wanted to add

相关标签:
1条回答
  • 2020-12-21 20:48

    When you click a button inside of a form, the default browser behavior is to submit the form which causes another HTTP request and reloads the page. In order to avoid this, your event handler needs to explicitly prevent the default behavior:

    Template.solBox.events({
      'click #solve': function(e) {
        e.preventDefault();
        // the rest of your code goes here
      }
    });
    
    0 讨论(0)
提交回复
热议问题