Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4830

Sharing common javascript code / functions between components

$
0
0

@emanuk wrote:

Hi there,

I can’t figure out how I can share some simple JavaScript functions between components.

For example, see below some code for an action inside a component. I want to share the function deactivate_other_filter_menus inside an action in another component but after a lot of searching on the net, I don’t see a clear solution.

TIA

-Emmanuel

import Ember from 'ember';

export default Ember.Component.extend({
  actions: {
    filtrer(filtre, event) {
      let elem = Ember.$(event.target);
(...)
      function deactivate_other_filter_menus(my_buttons_names) {
        Ember.$(my_buttons_names).each(function(index) {
          Ember.$("button[data-filtre='" + my_buttons_names[index] + "']")
          .removeClass('active')
        });
      }
 (...)
      return true;
    }
  }
});

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4830

Trending Articles