D
D
dreamniker2016-02-24 22:53:53
JavaScript
dreamniker, 2016-02-24 22:53:53

Where should the Javascript code be located in order to be executed only on one page of the site on Meteor.js?

There is a lot of code for processing actions with forms on one page of the site, is it possible to somehow make this code load only when the user goes to this page?
Or, let's say there are two buttons with the same id on different pages of the site, and each has its own handler connected via the button id, and if two handlers are always loaded, then only one of them will work for two buttons at once. And it is necessary that one code works on one page, and another on the other.
Maybe then the code of these handlers needs to be written in the template helper (is it possible to write such code there that will be called by clicking on the button?), Or put the .js files with the code in a specific directory and somehow configure the routing so that different pages are loaded for different files? Or in any case, all js files in the meteor will be collected into one file that works on all pages of the site?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Wolf, 2016-02-24
@mannaro

Template.tmplName.events({
  'click #button': function(e, tmpl) {
    // your code here
  }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question